Dictionary Basics
ID | 266 |
---|---|
Link Reference | Not set |
Link Credits | Not set |
Link Technical Documentation | Not set |
PlCodelang | MS Access VBA |
PlGroup | Array |
PlItemTitle | Dictionary Basics |
Code | ' empty dict Dim myDict As Dictionary Set myDict = New Dictionary ' some static values myDict.Add "key1", "value1" myDict.Add "key2", "valueY" myDict.Add "keyX", "value98" ' update a key programmatically myDict.Remove "key1" myDict.Add "key1", "new value" ' iterate Dim strKey As Variant Dim current_key As String Dim strValue As String For Each strKey In myDict.Keys() current_key = strKey strValue = myDict.Keys(strKey) Next ' Exists If myDict.Exists(strKey) Then Debug.Print "yes" End If ' get an specific item Dim subdict As String subdict = myDict.Keys("key2") # valueY |
Result Example |