我正在使用vba,并且已将某些值写入字典。但是,我想看看信息是否正确传递到字典中。因此,是否可以将字典中的键和值调试到当前窗口?
我在想这个:
debug.print DicTemp.Items
谢谢!
答案 0 :(得分:2)
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
答案 1 :(得分:1)
浏览每个字典键,并调试打印:
Dim key As Variant
For Each key In dict.Keys
Debug.Print key, dict(key)
Next key