CompareMode Property
Updated: April 2009
Sets and returns the comparison mode for comparing string keys in a Dictionary object.
object
.CompareMode[ = compare]
An error occurs if you try to change the comparison mode of a Dictionary object that already contains data.
The following example illustrates the use of the CompareMode property:
function TestCompareMode(key) { var BinaryCompare = 0, TextCompare = 1; var d = new ActiveXObject("Scripting.Dictionary"); // The comparison mode is Text, so the keys are case-insensitive. d.CompareMode = TextCompare; d.Add("a", "Athens"); d.Add("b", "Belgrade"); d.Add("c", "Cairo"); return(d.Item(key)); }
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"
' An error occurs on the next line because the key already exists.
' The comparison mode is Text, so the keys are case-insensitive.
d.Add "B", "Baltimore"
Applies To:
Community Additions
Show: