From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

Dictionary.HasKey(Key As Variant) As Boolean

Supported on Desktop, Web, Console.

Returns True if Key is in the Dictionary and False if it is not.


Returns a Boolean. The HasKey function is encoding-sensitive. The Dictionary works off hash functions and the hash of a UTF-16 string is vastly different from the hash of a UTF-8 string.

Sample Code

This example checks to see if the key corresponding to the passed color is in the Dictionary.

If d.HasKey(Color.Red) Then
MessageBox("The Red Key is not in the dictionary.")
End If