在VBA中更改嵌套字典

编程入门 行业动态 更新时间:2024-10-24 16:29:28
本文介绍了在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中更改嵌套字典

本文发布于:2023-11-12 03:42:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580410.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:嵌套   字典   VBA

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!