Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add to Collection (max limit?)

Status
Not open for further replies.

musico

Programmer
Jun 6, 2000
2
US
I have a simple collection which I'm storing many strings to represent file paths & names.

I add each string to the collect with no problem, until I try and add the 257th item. Then nothing ... no error ... no warning ... but the collect count is still 256 with out the new item added or replacing other itmes in the collection. Is there a limit the number of items in a collection?

Example of code:

Dim colFiles As Collection 'A collection to hold file
'Instanciate the two collections for use.
Set colFiles = New Collection

Do
....
...more code

'Add this file to the top of the collection of files.
colFiles.Add filestring
Loop
 
There probably is a limit to the max number of elements in a collection (I would guess the limit would be related to the amount of available memory), but if there is, I know that is is A LOT MORE THAN 256. I have had collections with several thousand elements. Post the EXACT code where you are seeing this and I'll take a look at it for you. - Jeff Marler B-)
 
Okay my mistake the collection takes items after 256, it's just the locals window is only displays the first 256. So when I was checking my code and only saw 256, I erroneously concluded there was a problem.
 
it's just the locals window is only displays the first 256.

The Immediate window won't display more than 32767 characters, either (had a coworker get caught by that one).

Chip H.
 
"32767 characters"

Wow . . . that's a long string to have to read in the immediate window. ;-) - Jeff Marler B-)
 
Yeah, he was trying to debug.print a XML file that he had read in...

Chip H.
 
As the Count property of a Collection object returns a Long, I guess that the maximum number of Items is 2.147.483.647 You'll probably run out of memory before you hit that wall... _________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]
 
rvBasic,
Good point! I would have to agree the you would run out of memory well before hitting 2 billion items in a collections. And now we know the max number of items allowed in the collection object. (an for the life of me, I don't know why I didn't think of just looking to see the variable type being returned by the count property |-I). - Jeff Marler B-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top