VBS using SCRIPTING.DICTIONARY Dictionary objects
Tags: scripting.dictionary, VBS, VBScript, dictionary
Title: VBS using SCRIPTING.DICTIONARY Dictionary objects
Author: Demon
Links: http://demon.tw/copy-paste/vbs-scripting-dictionary-object.html
Copyright: All articles of this blog are subject to the terms "Attribution-NonCommercial use-share 2.5 mainland China" in the same way.
Scripting.Dictionary is a useful component that creates a Dictionary object similar to the value of a key index, and provides a mechanism for fast index access within it, allowing us to index directly to the specified value via key, which is much more efficient than traversing a two-dimensional array.
This is how it is accessed in VBScript.
Dim Objdictset objdict = WSH. CreateObject ("Scripting.Dictionary") '. ADD (key, value) Objdict.add "A", "value1" Objdict.add "B", "value2" Objdict.add "C", "value3" directly through key= b Index to Value2wsh.echo (Objdict.item ("B")) Objdict.remove ("B") ' Delete index B and its corresponding value ' below is the traversal dictionary Dim objkeys, objitems, Iobjkeys = Objdict.keysobjitems = Objdict.itemsfor i = 0 to objdict.count-1 WSH. Echo ("key=" & Objkeys (i) & _ "and value=" & Objitems (i)); Next ' determines if the specified key exists if objdict.exists ("B") then WSH. Echo ("Found it") Else WSH. Echo ("Not exists!") End Ifobjdict.removeall ' Clears all keys in the dictionary and their corresponding valueset objdict = Nothing
Original link: http://wangye.org/blog/archives/60/
Related articles:
- VBS scripting.dictionary Dictionary object key name key to bubble sort
- QWERTY password: Encryption and decryption
- Rethinking the efficiency of VBS--processing binary data
- Implementation of Bencode algorithm with VBS
- Efficiency issues with string joins in VBS
VBS using SCRIPTING.DICTIONARY Dictionary objects