【问题标题】:How do I Debug Print keys and values in dictionary using VBA?如何使用 VBA 调试字典中的打印键和值?
【发布时间】:2018-07-16 09:24:43
【问题描述】:

我正在使用 vba 并将某些值写入字典。但是,我想看看信息是否已正确传递到字典中。因此,是否可以将字典中的键和值调试打印到即时窗口?

我在想这个:

debug.print DicTemp.Items

谢谢!

【问题讨论】:

    标签: vba excel


    【解决方案1】:
    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 
    

    【讨论】:

      【解决方案2】:

      遍历每个字典键,并调试打印:

      Dim key As Variant
      For Each key In dict.Keys
          Debug.Print key, dict(key)
      Next key
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-08-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-12-26
        • 1970-01-01
        相关资源
        最近更新 更多