IDictionary.CompareMode Property

Started by José Roca, July 13, 2008, 10:35:52 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca



The following example illustrates the use of the CompareMethod method.

JScript


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));
}


VBScript


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.


PowerBASIC


DIM d AS IDictionary
DIM vKey AS VARIANT
DIM vItem AS VARIANT
d = NEWCOM "Scripting.Dictionary"
d.CompareMode = %CompareMethod_TextCompare
vKey = "a" : vItem = "Athens"
d.Add vKey, vItem
vKey = "b" : vItem = "Belgrade"
d.Add vKey, vItem
vKey = "c" : vItem = "Cairo"
d.Add vKey, vItem
' Add method fails on this line because the
' letter b already exists in the Dictionary.
vKey = "B" : vItem = "Baltimore"
d.Add vKey, vItem