Version: 2.0
The Dictionary object stores name/value pairs (referred to as the key and item respectively) in an array. The key is a unique identifier for the corresponding item and cannot be used for any other item in the same Dictionary object.
<%
Dim cars
Set cars = CreateObject("Scripting.Dictionary")
cars.Add "a", "Alvis"
cars.Add "b", "Buick"
cars.Add "c", "Cadillac"
Response.Write "The value corresponding to the key 'b' is "
cars.Item("b")
%>
"The value corresponding to the key 'b' is
Buick"
This code creates a Dictionary object called "cars", adds some key/item pairs, retrieves the item value for the key 'b' using the Item property and then outputs the resulting string to the browser.
Syntax: object.CompareMode[ = comparison_mode]
The CompareMode property is used to set and return the key's string comparison mode which determines how keys are matched while looking up or searching. Syntax: object. Count Property Syntax: object.
Syntax: object.Count
The Count property is used to determine the number of key/item pairs in the Dictionary object.
Syntax: object.(key) [ = itemvalue]
The Item property allows us to retreive the value of an item in the collection designated by the specified key argument and also to set that value by using itemvalue.
Syntax: object.Key(keyvalue) = newkeyvalue
The Key property lets us change the key value of an existing key/item pair.
Syntax: object.Add keyvalue, itemvalue
The Add method is used to add a new key/item pair to a Dictionary object.
Syntax: object.Exists (keyvalue)
The Exists method is used to determine whether a key already exists in the specified Dictionary. Returns True if it does and False otherwise.
Syntax: [arrayname = ] object. Items
The Items method is used to retreive all of the items in a particular Dictionary object and store them in an array.
Syntax: object.Keys
The Keys method is used to retreive all of the keys in a particular Dictionary object and store them in an array.
Syntax: object.Remove(keyvalue)
The Remove method is used to remove a single key/item pair from the specified Dictionary object.
Syntax: object.RemoveAll
The RemoveAll method is used to remove all the key/item pairs from the specified Dictionary object.