• Reporting of Colections in Locals WIndow (Excel VBA (all?))

    Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Reporting of Colections in Locals WIndow (Excel VBA (all?))

    Author
    Topic
    #407781

    You can run code like this:

    Sub Test()
        Dim Coll As New Collection
        Dim lArray(1 To 500) As Long
        Dim x As Long
        For x = 1 To 500
            lArray(x) = x
            Coll.Add x
        Next
    End Sub

    o create an array of 500 values and a collection of 500 values. If you put a break on the “end sub” you can stop the code and look at the variables in the locals window. The Array shows all 500 items, but the items in the collection only show 256. Further investigation (dumping it to an array, a range, or checking the items, etc) demonstrates that the collection contains all 500 items, it just does not seem to show them all in the locals window.

    Is this a known bug in XL97? Does it still exist in other versions? Is it really an issue that needs to be worried about?

    Steve

    Viewing 5 reply threads
    Author
    Replies
    • #855657

      I can verify that it behaves the same way in 2K.

    • #855658

      I can verify that it behaves the same way in 2K.

    • #855688

      And the same in Office XP (2002) VBA too – this is not surprising, because Office XP and Office 2000 both use Visual Basic 6.3.

    • #855689

      And the same in Office XP (2002) VBA too – this is not surprising, because Office XP and Office 2000 both use Visual Basic 6.3.

    • #855824

      Same in ’03, Steve.

      Some time back Charlotte pointed out to me in the VBA Forum that she has had occasional problems with:

      For Each Object in Collection

      and she avoids those problems (and following her advice, so do I) by using

      For lCounter = 1 to Collection.Count
      Collection(lCounter).whatever

      Wonder if the issues are related.

      • #855903

        Don’t know if it is related, but I could use for each to put all 500 items into the spreadsheet without issue, so in this example it did not stop at 256.

        Steve

      • #855904

        Don’t know if it is related, but I could use for each to put all 500 items into the spreadsheet without issue, so in this example it did not stop at 256.

        Steve

    • #855825

      Same in ’03, Steve.

      Some time back Charlotte pointed out to me in the VBA Forum that she has had occasional problems with:

      For Each Object in Collection

      and she avoids those problems (and following her advice, so do I) by using

      For lCounter = 1 to Collection.Count
      Collection(lCounter).whatever

      Wonder if the issues are related.

    Viewing 5 reply threads
    Reply To: Reporting of Colections in Locals WIndow (Excel VBA (all?))

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: