VBScript » Dictionary » Item

Version: 2.0

Syntax:
object.(key) [ = itemvalue]
Keyvalue
The value of the key associated with the item being returned or set.
Itemvalue
An optional value which sets the value of the item associated with a key.

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.

The Item property sets or returns the value of an item for the specified key and Dictionary.

Keyvalue is the value of the key associated with the item being returned or set and itemvalue is an optional value which sets the value of the item associated with that key.

If the specified key is not found when attempting to change an item, a new key/item pair is added to the dictionary. If the key is not found while trying to return an existing item, a new key is added and the item value is left empty.

Examples

Code:
<%
Set d = CreateObject("Scripting.Dictionary")
d.Add "a", "Alvis" 'Add some keys and items.
d.Add "b", "Buick"
d.Add "c", "Cadillac"
d.Item("c") = "Corvette"
Response.Write "Value associated with key 'c' has changed to "
d.Item("c")
%>
Output:
"Value associated with key 'c' has changed to Corvette"