From Xojo Documentation


Dictionary.Value(key As Variant) As Variant

Supported for all project types and targets.

Retrieves the value associated with the key item.


Dictionary.Value(key As Variant, Assigns newValue As Variant)

Supported for all project types and targets.

Assigns a value to the key item in the Dictionary.


The Value function is encoding-sensitive. The Dictionary works of hash functions and the hash of a UTF-16 string is vastly different than the hash of a UTF-8 string.

If you attempt to read a value for a key that is not in the dictionary, a KeyNotFoundException error is raised. To avoid the exception, use the Lookup method to provide a default value if the key is not found or use the HasKey method to check if the key exists.

Sample Code

The Dictionary example in the Examples folder allows you to enter and display Dictionary entries. It uses only strings for the key and value, but you can actually use any type that can be stored as a Variant. The fields keyfield and valuefield contain the new key:value pair.

To use the example, enter a key and value pair and then press the “Set Value for Key” button. Its code is:

// add a value the same way you would set the value
// the key is a variant, which means it can be
// any data type.
// the value is also a variant
// however, this example only uses strings for keys and values

myDictionary.Value(keyField.Value) = ValueField.Value


UpdateListbox is a window method and it repopulates the ListBox.


For Each entry As DictionaryEntry In MyDictionary