Collection Object, 255 item limitation

T

timothy

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
 
J

Jim Cone

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"
<[email protected]>
wrote in message
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
 
T

timothy

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.
 
T

Tom Ogilvy

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.
 
T

timothy

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top