VBSCript中字典对象如何识别密钥,我的意思是说它将“ABC”和“BCA”视为同一个密钥......? 意思是我正在尝试这个,它给了我一个错误,这个密钥已经存在,所以任何人都可以请它提供一些细节。
答案 0 :(得分:1)
不是答案,但我需要格式化来指出VBScript的词典/争议AutomatedChaos声称的一种特殊性。 Scripting.Dictionary接受所有简单/标量数据类型甚至对象的键。因此,有两个键42和“42”是没有问题的:
>> set dic = CreateObject("Scripting.Dictionary")
>> dic.Add "42", 1
>> dic.Add 42, 2
>>
>> WScript.Echo Join(dic.Keys)
>>
42 42
答案 1 :(得分:0)
dictionary.key是Dictionary对象下存储项的指示符。
Microsoft Dictionary.Key Example:
'Dictionary.Item("{key}") returns the item information.
'Dictionary.Key("{oldkey}") = "{newkey}" stores a new key for a Dictionary entry.
Function DictDemo
Dim d ' Create some variables.
Set d = CreateObject("Scripting.Dictionary")
d.Add "a", "Athens" ' Add some keys and items, "a" = key, "Athens" = item
d.Add "b", "Belgrade"
d.Add "c", "Cairo"
d.Key("c") = "d" ' Set key for "c" to "d".
DictDemo = d.Item("d") ' Return associate item.
End Function
How to discover which keys you have populated
Function DictDemo
Dim a, d, i ' Create some variables.
Set d = CreateObject("Scripting.Dictionary")
d.Add "a", "Athens" ' Add some keys and items.
d.Add "b", "Belgrade"
d.Add "c", "Cairo"
a = d.Keys ' Get the keys.
For i = 0 To d.Count -1 ' Iterate the array.
s = s & a(i) & "<BR>" ' Return results.
Next
DictDemo = s
End Function