DIAdem Help

Property: Item for Dictionary

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

Property: Item for Dictionary

Returns the Dictionary collection element that belongs to a specific key.

Object.Item(Key)
ObjectDictionary
Object with this property
KeyVariant
Specifies the key.
Object.ItemVariant

The following example generates a Dictionary collection and adds some key/element pairs. Then the example displays the element that belongs to the "b" key:

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

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)

See Also

Objects Overview

Log in to get a better experience