ASP CompareMode 属性
ASP CompareMode 属性用于返回和设置比较字典对象中的键的数据比较模式。数据比较模式可以有以下值。
- vbBinaryCompare (0):这指定二进制比较将用于数据。
- vbTextCompare (1):这指定文本比较将用于数据。
- vbDatabaseCompare (2):这指定数据库比较将用于数据。
句法:
DictionaryObject.CompareMode[=compare]
参数:此属性有一个参数,如上所述,如下所述:
- compare:用于指定 Dictionary 对象中的比较方式。它是一个可选参数。
下面的示例演示了 ASP Dictionary.CompareMode 属性。
例子:
ASP
<%
dim dic
'Create a dictionary object
set dic=Server.CreateObject("Scripting.Dictionary")
'Set the comparison mode to be used
dic.CompareMode=1
'Add some key-value pairs to the dictionary
dic.Add "s","sudo"
dic.Add "c","competitive"
'Trying to add a new key that does not exists
dic.Add "p","placements"
Response.Write("The 'p' key-value was successfully added!")
'Trying to add a new key that already exists
'This will fail as the already exists!
dic.Add "c","code"
Response.Write("The 'c' key-value was successfully added!")
%>
输出:
The 'p' key-value was successfully added!
An error occurred on the server when processing the URL.