Dictionary Key Property VB

Data Type

String

Dictionary.Key Property (VB6) 229

Named Arguments

Syntax

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.

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. Property Data Type A String. Description

Returns the key or replaces an existing key with a new one. Rules at a Glance

• 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.

Example

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

230 Chapter 7- The Language Reference

Was this article helpful?

0 0

Post a comment