ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Collection Object, 255 item limitation (https://www.excelbanter.com/excel-programming/339746-collection-object-255-item-limitation.html)

timothy[_2_]

Collection Object, 255 item limitation
 
Hi

It appears I have run into a 255 item limitiation in VBA with the
"Collection" object. Anyone have any ideas?

This is what I have defined as <Code:

< Public gcolE_Defs() As New Collection

then when I execute the following code

< gcolE_Defs(i).ADD Item:=oED, key:=CStr(iCount)

and the iCount is beyond 255 or 256 it stops adding items to the
collection.

Anyone have any ideas?????

Timothy Marks


Jim Cone

Collection Object, 255 item limitation
 
Timothy,

It appears the syntax for the collection is incorrect.
Try...
gcolE_Defs.Add Item:=oED, Key:=CStr(iCount)

Regards,
Jim Cone
San Francisco, USA


"timothy"

wrote in message
ups.com
Hi
It appears I have run into a 255 item limitiation in VBA with the
"Collection" object. Anyone have any ideas?
This is what I have defined as <Code:

< Public gcolE_Defs() As New Collection
then when I execute the following code
< gcolE_Defs(i).ADD Item:=oED, key:=CStr(iCount)
and the iCount is beyond 255 or 256 it stops adding items to the
collection.
Anyone have any ideas?????
Timothy Marks

timothy[_2_]

Collection Object, 255 item limitation
 
Hi Jim

I purposely dimensioned the collection as a multi-dimensional
collection object in my public statement by using ().

So gcolE_Defs(i) is a proper reference to gcolE_Defs. At some point in
my code I define a variable amount of dimensions so I can loop through
ambiguous sets of data determined at runtime.

Timothy.


Tom Ogilvy

Collection Object, 255 item limitation
 
Public gcolE_Defs() As New Collection


Sub ABC()
ReDim gcolE_Defs(1 To 3)
For i = 1 To 3
For icount = 1 To Int(Rnd() * 1000 + 4500)
oED = Int(Rnd() * 10000 + 1)
gcolE_Defs(i).Add Item:=oED, key:=CStr(icount)
Next
Next
For i = 1 To 3
Debug.Print "gcolE_Defs(" & i & ") count is " & _
gcolE_Defs(i).Count & " last value is: " & _
gcolE_Defs(i).Item(gcolE_Defs(i).Count)
Next
End Sub

produced:
gcolE_Defs(1) count is 5205 last value is: 4011
gcolE_Defs(2) count is 5155 last value is: 3229
gcolE_Defs(3) count is 4804 last value is: 1691

So 255 doesn't appear to be a limit.

--
Regards,
Tom Ogilvy


"timothy" wrote in message
oups.com...
Hi Jim

I purposely dimensioned the collection as a multi-dimensional
collection object in my public statement by using ().

So gcolE_Defs(i) is a proper reference to gcolE_Defs. At some point in
my code I define a variable amount of dimensions so I can loop through
ambiguous sets of data determined at runtime.

Timothy.




timothy[_2_]

Collection Object, 255 item limitation
 
Hi Tom

You may be right.

It appears the Watch editor in VBA is limited to 255 item limit. This
is what I was going by. I figured what I couldn't see didn't exist.

Timothy.



All times are GMT +1. The time now is 05:23 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com