DIAdem Help

Method: Exists for Dictionary

  • Updated2024-09-12
  • 1 minute(s) read

Method: Exists for Dictionary

Checks whether there is a key in a Dictionary collection.

bExists = Object.Exists(Key)
ObjectDictionary
Object with this method
KeyVariant
Specifies the key.
bExistsBoolean
If the key exists, the value is True. If the key does not exist, the value is False.

The following example generates a Dictionary collection and adds some key/element pairs. Then the example checks whether the key "a" exists:

Dim MyDic
Set MyDic = CreateObject("Scripting.Dictionary")
Call MyDic.Add ("a", "Austin")
Call MyDic.Add ("b", "Berlin")
Call MyDic.Add ("c", "Chicago")
If MyDic.Exists("a") Then
  Call MsgBox("Key 'a' already exists")
Else
  Call MyDic.Add ("a", "Aachen")
End If

Log in to get a better experience