Dictionary.Key Property (VB6) |
String
Yes
The syntax for setting a new key is:
dictionaryobject.Key(key) = newkey
dictionaryobject
Use: Required
Data Type: Dictionary object
A reference to a Dictionary object.
key
Use: Required
Data Type: String
A unique string key for this Dictionary object.
newkey
Use: Required
Data Type: String
A unique string key for this Dictionary object.
A String.
Returns the key or replaces an existing key with a new one.
As with the Item property, if a key that you are attempting to change doesn't exist, the new key is added to the dictionary and is linked to a blank item.
A concept unknown to users of the Collection object is the ability to change the key associated with an item; however, this is easy with the Dictionary object, as the example demonstrates.
Private Function ChangeKeyValue(sOldKey As String, _ sNewKey As String) _ As Boolean If oDictionary.Exists(sOldKey) Then oDictionary.Key(sOldKey) = sNewKey ChangeKeyValue = True Else ChangeKeyValue = False End If End Function