Author Topic: IDictionary.CompareMode Property  (Read 2253 times)

0 Members and 1 Guest are viewing this topic.

Online Josť Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2480
    • Josť Roca Software
IDictionary.CompareMode Property
« on: July 13, 2008, 10:35:52 PM »

The following example illustrates the use of the CompareMethod method.

JScript

Code: [Select]
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

Code: [Select]
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

Code: [Select]
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
« Last Edit: July 13, 2008, 10:55:23 PM by Josť Roca »