The scripting.dictionary of VBScript creates a Dictionary object that is similar to the value of the key index, indexed directly to the specified value.
Examples of scripting.dictionary use in VBScript are as follows:
Copy Code code as follows:
Dim objdict
Set objdict = WSH. CreateObject ("Scripting.Dictionary")
' . ADD (key, value)
Objdict.add "A", "value1"
Objdict.add "B", "value2"
Objdict.add "C", "Value3"
' Directly via Key=b index to value2
WSH. Echo Objdict.item ("B")
Objdict.remove "B" deletes index B and its corresponding value
' The following is the traversal dictionary
Dim Objkeys, Objitems, I
Objkeys = Objdict.keys
Objitems = Objdict.items
For i = 0 to Objdict.count-1
WSH. Echo "key=" & Objkeys (i) &_
"and Value=" & Objitems (i)
Next
' Determines whether the specified key exists
If objdict.exists ("B") Then
WSH. Echo "Found It"
Else
WSH. Echo "Not exists!"
End If
Objdict.removeall ' Clears all keys in the dictionary and their corresponding value
Set objdict = Nothing