...

View Full Version : Collections in VB2003



soper87
09-03-2009, 09:55 AM
I am using code that unfortunately uses collections, I'm not sure why it does but it does. Is there any way of adding multiple items to a collection?

At the moment it has:

CType(stat(sta), collection.Add(item)

I want to have it contain item one and two, similar to:

.Add(item1 && item2)

Is this possible or will I have to create an array list or collection of collections??

Cheers
Chris

oracleguy
09-03-2009, 03:43 PM
Can you not just call collection.Add() twice? Once for each item?

soper87
09-04-2009, 08:18 AM
I have tried that but then the display doesn't seem to work properly. The system uses a hash table firstly and then adds in the ID number, done using i = i+1 in a for loop, before adding the items. It seems to work with adding just the ID number and item 1 but when attempting to add item 3 it tends to break. Reading through a VB 'bible' just now to if I can suss it out

oracleguy
09-04-2009, 04:00 PM
Post a little bit more code so the lines you posted previously are put in more context.

ghell
09-08-2009, 05:22 PM
Correct me if I'm wrong but isn't VB2003 a .net language? As in Visual Studio 7 or Visual Studio .NET? It should be using the .net framework 1.1 by default so here (http://msdn.microsoft.com/en-us/library/system.collections%28VS.71%29.aspx) is the documentation on collections in .net 1.1.

If this is correct, try AddRange instead of just Add.

I can't see why multiple calls to Add wouldn't just work though. I'm pretty sure that in these collections, order is by no means guaranteed if that is what your problem is.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum