Scripting.Dictionary 还在 VBA 中常用吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13249417/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 18:22:40  来源:igfitidea点击:

Scripting.Dictionary still commonly used in VBA?

excel-vbavbaexcel

提问by Ian

I had to cobble together some code in Excel/VBA and vaguely remember we used to add a reference to Microsoft Scripting Runtime to use Dictionary. Now in the days of Office 2010, is that still the preferred way of getting access to a Dictionary like structure or have things moved on?

我不得不在 Excel/VBA 中拼凑一些代码,并且依稀记得我们曾经添加对 Microsoft Scripting Runtime 的引用以使用 Dictionary。现在在 Office 2010 的时代,这仍然是访问类似结构的字典的首选方式还是让事情继续发展?

回答by Ahmad

Dictionaries are still used the same old way in Excel VBA -- Read more here Does VBA have Dictionary Structure?

字典在 Excel VBA 中仍然使用相同的旧方式——在此处阅读更多内容 VBA 是否具有字典结构?

But there is an alternative to dictionary objects, using CollectionsMore about that here: Using Dictionary Object in Excel VBA

但是有一个字典对象的替代方法,使用Collections更多关于这里的信息:在 Excel VBA 中使用字典对象

回答by Tomas Hesse

Be aware! Microsoft Scripting Runtime does not work on Mac. There is a workaround though. Get this https://github.com/VBA-tools/VBA-Dictionaryand import Dictionary.cls into your VBA project. This will create a Dictionary class that will be used instead of the one in Microsoft Scripting Runtime

意识到!Microsoft Scripting Runtime 在 Mac 上不起作用。不过有一个解决方法。获取此https://github.com/VBA-tools/VBA-Dictionary并将 Dictionary.cls 导入到您的 VBA 项目中。这将创建一个 Dictionary 类,用于代替 Microsoft Scripting Runtime 中的一个