Dictionary objects are key value pairs object.One of the use of dictionary can be to find unique elements in a given set of data.
Below is the example of the methods that can be used in dictionary:
Set objDict=CreateObject(“Scripting.Dictionary”)
objDict.Add “1”,”test6″ ‘Add method is used to add unique key with a value to dictionary
objDict.Add “2”,”test2″
objDict.Add “3”,”test3″
objDict.Add “7”,”test7″
‘msgbox objDict.CompareMode
‘msgbox objDict.Count ‘Count method return the no of key-value pairs present in the dictionary.
objDict.Key(“1″)=”6” ‘key method is used to read/modify the value associated with the key
‘msgbox objDict.Exists(“6”) ‘Exists method check whether the given key is present in the dictionary or not.return value is true/false
keys=objDict.Keys ‘keys method returns a collection of all the keys present in the dictionary
For each key in keys
msgbox objDict.Item(key) ‘Item method return the value stored for the specified key.