我正在使用 vba 并将某些值写入字典。但是,我想看看信息是否已正确传递到字典中。因此,是否可以将字典中的键和值 debug.print 到即时窗口?
我在想这个:
debug.print DicTemp.Items
Run Code Online (Sandbox Code Playgroud)
谢谢!
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
Run Code Online (Sandbox Code Playgroud)
它打印:
first 30
second 40
third 100
Run Code Online (Sandbox Code Playgroud)
循环遍历每个字典键,并调试打印:
Dim key As Variant
For Each key In dict.Keys
Debug.Print key, dict(key)
Next key
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11412 次 |
| 最近记录: |