如何使用VBA调试字典中的打印键和值? [英] How do I Debug Print keys and values in dictionary using VBA?
本文介绍了如何使用VBA调试字典中的打印键和值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用vba,并且已将某些值写入字典.但是,我想查看信息是否已正确传递到字典中.因此,是否可以将字典中的键和值调试到当前窗口?
I am using vba and have written certain values into the dictionary. However, I would like to see if information has been passed into the dictionary correctly. Hence, is it possible to debug.print keys and values in a dictionary to the immediate window?
我在想这个:
debug.print DicTemp.Items
谢谢!
推荐答案
Public Sub TestMe()
Dim dict As Object
Set dict = CreateObject("Scripting.Dictionary")
dict.Add "first", 30
dict.Add "second", 40
dict.Add "third", 100
Dim key As Variant
For Each key In dict.Keys
Debug.Print key, dict(key)
Next key
End Sub
它打印:
first 30
second 40
third 100
这篇关于如何使用VBA调试字典中的打印键和值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文