我不太确定你的问题是什么,所以我试验了一下.
您似乎错过了为对象分配引用,您必须使用set
,即使是返回值:
Function GetSomeStuff Dim stuff Set stuff = CreateObject("Scripting.Dictionary") stuff.Add "A", "Anaconda" stuff.Add "B", "Boa" stuff.Add "C", "Cobra" Set GetSomeStuff = stuff End Function Set d = GetSomeStuff Wscript.Echo d.Item("A") Wscript.Echo d.Exists("B") items = d.Items For i = 0 To UBound(items) Wscript.Echo items(i) Next