VBScript » Dictionary » Add

Version: 2.0

Syntax:
object.Add keyvalue, itemvalue
Itemvalue
An optional value which sets the value of the item associated with a key.
Keyvalue
The value of the key associated with the item being returned or set.

The Add method is used to add a new key/item pair to a Dictionary object.

Be aware that an error will occur if the key already exists.

Examples

Code:
<%
dim guitars
set guitars=CreateObject("Scripting.Dictionary")
guitars.Add "e", "Epiphone"
guitars.Add "f", "Fender"
guitars.Add "g", "Gibson"
guitars.Add "h", "Harmony"
%>
Output:
"Epiphone"
"Fender"
"Gibson"
"Harmony"
Explanation:

This example adds several key/item pairs to a Dictionary object called 'guitars'.