Dictionary.Add Method (VB6)

Named Arguments

Yes

Syntax

dictionaryobject.Add key, item


dictionaryobject

Use: Required

Data Type: Dictionary object

A reference to a Dictionary object.


key

Use: Required

Data Type: String

A key value that's unique in the Dictionary object.


item

Use: Required

Data Type: Object

The item to be added to the dictionary.

Description

Adds a key and its associated item to the specified Dictionary object.

Rules at a Glance

  • If the key isn't unique, runtime error 457, "This key is already associated with an element of this collection," is generated.

  • item can be of any data type, including objects and other Dictionary objects.

Example

Set oDict = New Dictionary 
    iVal = 1  
    Set oTest = New clsTest
        With oTest
            .Age = 10
            .Phone = "0112 31234"
            .TestName = "Russell"
        End With
        
        oDict.Add CStr(iVal), oTest
    Set oTest = Nothing

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

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