如何监控在Excel中VBA监视窗口在字典中的值? [英] How to monitor the values in a Dictionary in the Excel VBA watch window?

查看:2215
本文介绍了如何监控在Excel中VBA监视窗口在字典中的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过字典作为新词典使用Excel的VBA词典(并添加一个引用脚本运行时)。当我试图监视这些在调试过程中,我只能看到它趴在字典中的钥匙,但不是每个按键的相应数值。

I am using dictionaries in Excel VBA via dict As New Dictionary (and adding a reference to the scripting runtime). When I try to monitor those during debugging, I can only see the keys which lie in the dictionary, but not the respective value of each key.

有没有办法看到的价值呢?它将使调试更加方便我。

Is there any way to see the value as well? It would make debugging much more easy for me.

编辑:根据您的回答,有没有简单的解决办法,但我可以做到以下几点。

Based on your answers, there is no easy solution, but I can do the following.

使用全局变量暗淡d_obj为对象,并持续监控它,每当我需要查找一本字典的值,我键入到立即窗口设置d_obj(密钥)= ... 和我将能够看到在监视器窗口中的值。

Use a global variable Dim d_obj As Object and monitor it constantly and whenever I need to look up a value of a dictionary, I type into the immediate window Set d_obj(key) = ... and I will be able to see the value in the monitor-window.

我可以这样做,除了是写一个函数,它接受一个字典和返回值的列表,同样使用此功能的直接窗口。 THX大家!

What I may do in addition is write a function which takes in a dictionary and returns the values as a list and use this function similarly at the direct window. Thx to all!

推荐答案

我通常键入 dict.items 进入即时窗口,选择它,去Shift + F9插入入监视窗口。

I usually type dict.items into the immediate window, select it and go Shift+F9 to insert it into the watch window.

另外,这里有一个一行的即时窗口,列出所有项目:

Alternatively, here's a one-liner for the immediate window, to list all items:

for each i in dic.Items: debug.Print i: next

这篇关于如何监控在Excel中VBA监视窗口在字典中的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆