Dictionary.Key Property (VB6)

Data Type

String

Named Arguments

Yes

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.


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.

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

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset