Open In App

ASP CompareMode Property

The ASP CompareMode Property is used to return and set the data comparison mode which compares the keys in a Dictionary Object. The data comparison mode can have the following value.

Syntax:



DictionaryObject.CompareMode[=compare]

Parameter: This property has a single parameter as mentioned above and described below:

The below example demonstrates the ASP Dictionary.CompareMode Property.



Example:




<%
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!")
%>

Output:

The 'p' key-value was successfully added!
An error occurred on the server when processing the URL.
Article Tags :