In vbs, a special object-dictionnary is a collection object. Generally, Xia thinks of this special set as an array and can use built-in functions to store and manipulate data and other basic tasks without worrying about the ranks of data, instead, it uses a unique key for access or a database that can only run in the memory. There are only two fields: Key and item. in use, the field key is the index field.
Set sdict = Createobject ("scripting. Dictionary ")
Sdict. Add "A", "apple"
Sdict. Add "B", "banana"
Sdict. Add "C", "copy"
For each key in sdict. Keys
Msgbox "key name" & Key & "is" & "=" & sdict (key)
Next
Sdict. removeall
This script is simple. It defines the instance sdict of a dictionary object, adds three pieces of data, enumerates each piece of data, and finally clears the instance of the object.
Member summary of a dictionary object
Attributes and descriptions
Comparemode setting or string comparison mode of the Return key
Count read-only. Returns the number of key/entry pairs in a dictionary.
Item (key) sets or returns the entry value of the specified key
Key (key) set the key value
Methods and instructions
Add (Key, item) to add a key/entry pair to Dictionary
Exists (key) if the specified key exists, true is returned; otherwise, false is returned.
Items () returns an array containing all entries in the dictionary object
Keys () returns an array containing all keys in the dictionary object.
Remove (key) deletes a specified key/entry pair
Removeall () delete all key/entry Pairs