vbscript 中是否可以有对象/类的字典?
例如:
Class employeeclass
Public first, last, salary
End Class
Dim employeedict: Set employeedict = CreateObject("Scripting.Dictionary")
'Loop would be here
Dim employee: Set employee = new employeeclass
With employee
.first = "John"
.last = "Doe"
.salary = 50000
End With
employeedict.Add "1", employee
EDIT 以上确实有效.
(回答自己的问题)
是的,可以在 VBScript 中使用对象/类的字典。以下是一个例子,有兴趣的朋友可以参考一下:
Class employeeclass
Public first, last, salary
End Class
Dim employeedict: Set employeedict = CreateObject("Scripting.Dictionary")
Dim employee: Set employee = new employeeclass
With employee
.first = "John"
.last = "Doe"
.salary = 50000
End With
employeedict.Add "1", employee
Set employee = new employeeclass
With employee
.first = "Mary"
.last = "Jane"
.salary = 50000
End With
employeedict.Add "3", employee
Dim employeedetails: Set employeedetails = employeedict.Item("1")
WScript.StdOut.WriteLine("Name:" & employeedetails.first & " " & employeedetails.last & " $" & employeedetails.salary )
WScript.StdOut.WriteLine(employeedict.Item("3").first & " " & employeedict.Item("3").last & " makes $" & employeedict.Item("3").salary)
打印出:
Name:John Doe $50000
Mary Jane makes $50000
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)