Dictionary Add Method VB

Named Arguments

Syntax dictionaryobject.Add key, item dictionaryobject Use: Required

Data Type: Dictionary object A reference to a Dictionary object.

Use: Required Data Type: String

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

224 Chapter 7 - The Language Reference item

Use: Required

Data Type: String

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

.Phone = "0112 31234" .TestName = "Russell" End With oDict.Add CStr(iVal), oTest Set oTest = Nothing

Was this article helpful?

0 0

Post a comment