DICTIONARY OBJECT IN VB SCRIPT
The Dictionary objection stores name / value pairs in an array . The key is a unique identifier for the corresponding item and cannot be used for any othe item in the same dictionary object.
Example code:
<%
Dim cars
set cars =CreateObject("Scripting.Dictionary")
cars.Add "a","Toyoto"
cars.Add "b","Ford"
cars.Add "c","Benz"
Response.Write "The value of corresponding to the key 'b' is"" cars.Item("b")
%>
output:
The value of corresponding to the key 'b' is"Ford"
Explanation:
This code creates dictionary object called cars add some key/item pairs,retrieves the item value for the key b using the property and then outputs the resulting string to the broswer.
Properties :
compare mode:
syntax:
object.CampareMode[=comparison-mode]
The compare mode [property is used to set and return the key's string comparison mode which determines how keys are matched while looking up or searching
count:
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 allow 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 item value.
syntax:object.key(keyvalue)=nnewkeyvalue
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 in 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 item method is used to retreive all of the item in a particular dictionary object and store them in an array.
syntax:object.Keys
The Key method is used to retreive all of the key in a particular dictionary object and store them in an array.
Item:
syntax:object.(key)[=itemvalue]
The item property allow 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 item value.
Key:
syntax:object.key(keyvalue)=nnewkeyvalue
The key property lets us change the key value of an existing key/item pair.
Methods:
Add:
syntax:object.Add keyvalue, itemvalue
The add method is used to add a new key/item pair in a dictionary object.
Exists:
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.
Item:
syntax:[arrayname=] object.Items
The item method is used to retreive all of the item in a particular dictionary object and store them in an array.
Keys:
syntax:object.Keys
The Key method is used to retreive all of the key in a particular dictionary object and store them in an array.
Remove:
syntax:object.Remove(keyvalue)
The remove method is used to remove a single key/item pair from the specified dictionary object.
Remove All:
syntax:object.RemoveAll
The remove all method is used to remove all key/item pair from the specified dictionary object.
0 Comments