VBA Debugger shows only 256 elements of a collecti

2020-03-26 08:12发布

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.

3条回答
疯言疯语
2楼-- · 2020-03-26 08:42

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.

查看更多
Explosion°爆炸
3楼-- · 2020-03-26 08:46

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
查看更多
够拽才男人
4楼-- · 2020-03-26 09:01

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
查看更多
登录 后发表回答