From Xojo Documentation


Xojo.Core.Dictionary.Value(key As Auto, Assigns newValue As Auto)

Supported for all project types and targets.

Adds a new key-value pair to the Dictionary. If there is already an entry with the specified key, its value is altered and no exception is raised.


Xojo.Core.Dictionary.Value(key As Auto) As Auto

Supported for all project types and targets.

Returns the value associated with the specified key. If there is no such entry, a KeyNotFoundException is raised.


KeyNotFoundException when attempting to get a key that is not in the Dictionary.

Sample Code

As this is an assignment method, you use it with the assignment operator.

Var d As New Xojo.Core.Dictionary
d.Value(123) = "Jane Adams"

More Dictionary usage:

Var name As Text
name = d.Value(123)

Var id As Integer = d.Value("Age")
Label1.Value = id.ToText

If the Dictionary contains an array, you can iterate through by first assigning the value to an Auto array and then using the correct type in a For...Each loop. For example, this code gets an array of Dictionaries:

Var myAutoArray() As Auto = myDictionary.Value("KeyForArrayOfDictionaries")

Var value As Auto
For Each dict As Xojo.Core.Dictionary In myAutoArray
value = dict.Value("Test")