DIAdem Help

Collection: Dictionary

  • Updated2024-09-12
  • 1 minute(s) read

Collection: Dictionary

The Dictionary object provides an array with a key/element pair. The key and the element can have any data type, but the key cannot be an array. A Dictionary object is comparable with an associative array. To use the Dictionary object, you must create this object in DIAdem with the CreateObject("Scripting.Dictionary") command.

The following example generates a Dictionary collection and adds some key/element pairs:

Dim MyDic
Set MyDic = CreateObject("Scripting.Dictionary")
Call MyDic.Add("a", "Austin")  
Call MyDic.Add("b", "Berlin")
Call MyDic.Add("c", "Chicago")

The elements of a Dictionary collection can contain complex structures such as arrays and classes. The following example generates a Dictionary collection and adds some key/element pairs.The elements are arrays. Then the example displays the array that belongs to the "b" key:

Dim MyDic, MyItem, MyArrA, MyArrB, MyArrC, MyArrayItem, sOutPut
Set MyDic = CreateObject("Scripting.Dictionary")
MyArrA = Array("Austin", "Aachen", "Amsterdam")
MyArrB = Array("Berlin", "Bangalore", "Brussels")
MyArrC = Array("Chicago", "Cambridge", "Cannes")

Call MyDic.Add ("a", MyArrA)
Call MyDic.Add ("b", MyArrB)
Call MyDic.Add ("c", MyArrC)
MyItem = MyDic.Item("b")
sOutPut = "Elements of ""Item(b)"":" & VBCrLf
For Each MyArrayItem in MyItem
  sOutPut = sOutPut & MyArrayItem & VBCrLf
Next
Call MsgBox(sOutPut)

Properties

CompareMode | Count | Item | Key

Methods

Add | Exists | Items | Keys | Remove | RemoveAll

Log in to get a better experience