Sets and returns the comparison mode for comparing string keys in a Dictionary object.
A value representing the comparison mode. Acceptable values are 0 (Binary), 1 (Text), 2 (Database). Values greater than 2 can be used to refer to comparisons using specific Locale IDs (LCID).
The following example illustrates the use of the CompareMode property:
Using CompareMode (JScript) | Copy Code |
---|
function TestCompareMode(key)
{
// Create some variables.
var a, d;
var BinaryCompare = 0, TextCompare = 1;
d = new ActiveXObject("Scripting.Dictionary");
// Set Compare mode to Text.
d.CompareMode = TextCompare;
// Add some keys and items.
d.Add("a", "Athens");
d.Add("b", "Belgrade");
d.Add("c", "Cairo");
return(d.Item(key));
} |
Using CompareMode (Visual Basic) | Copy Code |
---|
Dim d
Set d = CreateObject("Scripting.Dictionary")
d.CompareMode = vbTextCompare
d.Add "a", "Athens" ' Add some keys and items.
d.Add "b", "Belgrade"
d.Add "c", "Cairo"
d.Add "B", "Baltimore" ' Add method fails on this line because the
' letter b already exists in the Dictionary. |