' This example needs "Microsoft Scripting Runtime"
'
' Dictionary (or Associative Array) example
option explicit
public sub dictionary()
dim dict as dictionary
set dict = new dictionary
dict.compareMode = binaryCompare
dict("one" ) = 1
dict("two" ) = 2
dict("three") = 3
dict("four" ) = 4
call print_value_of("three", dict)
call print_value_of("nine" , dict)
call print_key_value_pairs(dict)
end sub
private sub print_value_of(key_ as string, dict as dictionary)
if dict.exists(key_) then
msgBox("Value of " & key_ & " is " & dict(key_))
else
msgBox("Key " & key_ & " was not found in dict")
end if
end sub
private sub print_key_value_pairs (dict as dictionary)
dim key_ as variant
for each key_ in dict.keys
msgBox (key_ & "=" & dict(key_))
next
end sub