Microsoft Scripting Runtime
Add Method
The key associated with the item being added.
The item associated with the key being added.
Description
Adds a key and item pair to a Dictionary object.
Syntax
Visual Basic
Public Sub Add( _
   ByRef Key As Variant, _
   ByRef Item As Variant _
) 
Parameters
Key
The key associated with the item being added.
Item
The item associated with the key being added.
Remarks

An error occurs if the key already exists.

Example

The following example illustrates the use of the Add method.

Adding an item to the Dictionary (JScript)
Copy Code
var d;
d = new ActiveXObject("Scripting.Dictionary");
d.Add("a", "Athens");
d.Add("b", "Belgrade");
d.Add("c", "Cairo");
Adding an item to the Dictionary (Visual Basic)
Copy Code
Dim d   ' Create a variable.
Set d = CreateObject("Scripting.Dictionary")
d.Add "a", "Athens"   ' Add some keys and items.
d.Add "b", "Belgrade"
d.Add "c", "Cairo"
See Also

Dictionary Collection  | Dictionary Members  | Add Method  | Exists Method  | Items Method  | Keys Method  | Remove Method  | RemoveAll Method

Send feedback