vbscript dictonary问题

时间:2011-06-21 07:26:32

标签: vbscript

我在VBscript中使用字典。我有一些问题,我不明白一些行为:

Dim CmdData  
Set CmdData = CreateObject("System.Dictonary")  
CmdData.Add "11", "tttzz"  
CmdData.Add "sssid", "KRN"  
WScript.Echo(" ZZZZZZZZ= " & CmdData.Count)  'It prints zero and not 2

Dim s  
s = CmdData.Item("11")  
alert(s)  
WScript.Echo(s)   'It prints empry box and not tttzz

Dim a, j   
a = CmdData.Keys  
For j = 0 To CmdData.Count -1  
    WScript.Echo(" ZZZZZZZZ= " & CmdData.Count)   
    WScript.Echo(a(j)) ' doesn not print  
Next  

If (CmdData.Exists("-ad")) Then   
    'WScript.Echo (" RR ") ' It prints it although not in the dictonary  
End If  

由于

1 个答案:

答案 0 :(得分:3)

VBScript的词典是“Scripting.Dictionary”:

>> set syd = CreateObject("System.Dictionary")
>> syd.add "a",1
>>
Error Number:       429
Error Description:  ActiveX component can't create object
>> set scd = CreateObject("Scripting.Dictionary")
>> scd.add "a",1
>> WScript.Echo scd.Count, scd("a")
>>
1 1