VBA Debugger shows only 256 elements of a collection

匆匆过客 提交于 2020-02-16 05:50:11

问题


the title explains my problem. Im working on an excelmakro and my questions is, is there an option that the debugger shows all elements like it does with an array?

And if not, is the only workaround the storage of my classobjects in an array after inflating the collection?

I appreciate your help.


回答1:


You could use debug.print and write the output into the immediate window and bypass the limit that way.

I am almost certain that there is no way to increase that limit, but maybe someone else can give a def. answer on that.




回答2:


The answer seems to be no -- but the following sub might help. A simple experiment shows that it can be used in the immediate window while in debug mode:

Sub display(col As Collection)
    Dim i As Long
    Dim it As Variant
    Dim itType As String
    For i = 1 To col.Count
        it = col.Item(i)
        itType = TypeName(it)
        Debug.Print "Item " & i & " -- Value: " & it & " -- Type: " & itType
    Next i
End Sub



回答3:


In my case the elements of the collection could be arrays.

John Coleman's sub could be improved to cover (at least one-dimensional) arrays as:

Sub display(col As Collection)
    Dim i As Long
    Dim it As Variant
    Dim itType As String
    For i = 1 To col.Count
        it = col.item(i)
        itType = TypeName(it)
        If Not IsArray(it) Then
            Debug.Print "Item " & i & " -- Value: " & it & " -- Type: " & itType
        Else
            Debug.Print "Item " & i & " -- Values: [" & Join(it, ", ") & "] -- Type: " & itType
        End If
    Next i
End Sub


来源:https://stackoverflow.com/questions/30867105/vba-debugger-shows-only-256-elements-of-a-collection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!