VBA有字典结构吗?就像键<>值数组?
最佳答案
是的。
设置对 MS 脚本运行时(“Microsoft 脚本运行时”)的引用。根据 @regjo 的评论,转到“工具”->“引用”并勾选“Microsoft 脚本运行时”框。
使用下面的代码创建一个字典实例:
Set dict = CreateObject("Scripting.Dictionary")
或
Dim dict As New Scripting.Dictionary
使用示例:
If Not dict.Exists(key) Then
dict.Add key, value
End If
使用完字典后,不要忘记将其设置为Nothing
。
Set dict = Nothing
关于vba - VBA有字典结构吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/915317/