本文介绍了在VBA中更改嵌套字典的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在解决方案进行一次测试时,我即将提出一个问题。所以我正在发布和回答,所以其他人可以受益。
I was about to ask a question when the solution came in one test. So I'm posting anyway and answering, so others can benefit.
问题是:
我运行下面的代码并获得运行时错误450 - 参数数量错误或属性分配无效
I run the code below and get a runtime error 450 - Wrong number of arguments or invalid property assignment
Dim data, tmpDict As Dictionary Set data = New Dictionary Set tmpDict = New Dictionary data.Add 123, tmpDict Set tmpDict = data.Item(123) tmpDict.Add "somekey", 100 data.Item(123) = tmpDict错误发生在最后一行。该代码被简化为专注于更改现有项目中的嵌套字典。
The error occur in last line. The code was simplified to focus on changing a nested dictionary in an already existing item.
我该如何成功?
推荐答案解决方案可以通过以下方式实现最后3行订单:使用以下方式:
The solution can be achieved contracting the last 3 lines in just 1, using:
data.Item(123).Add "somekey", 100而不是: / p>
instead of:
Set tmpDict = data.Item(123) tmpDict.Add "somekey", 100 data.Item(123) = tmpDict更多推荐
在VBA中更改嵌套字典
发布评论