Dictionary

Dictionaries map keys to values and can store heterogeneous value types.

  • Instantiation

Dim dict As New Dictionary
dict.Value("apple") = 3
dict.Value("banana") = 5
* Basic Methods

Method Description
dict.Value(key) Get or set the value for key.
dict.ContainsKey(k) Returns True if k exists.
dict.Remove(k) Deletes entry with key k.
dict.Keys Returns an array of all keys.
dict.Items Returns an array of all values.
If dict.ContainsKey("apple") Then
  Print("Apples: " + Str(dict.Value("apple")))
End If

For Each key As Variant In dict.Keys
  Print(key + " => " + Str(dict.Value(key)))
Next