Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jul 2009
    Location
    Scotland
    Posts
    44
    Thanks
    2
    Thanked 1 Time in 1 Post

    Collections in VB2003

    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:
    Code:
    CType(stat(sta), collection.Add(item)
    I want to have it contain item one and two, similar to:
    Code:
    .Add(item1 && item2)
    Is this possible or will I have to create an array list or collection of collections??

    Cheers
    Chris

  • #2
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Can you not just call collection.Add() twice? Once for each item?
    OracleGuy

  • #3
    New Coder
    Join Date
    Jul 2009
    Location
    Scotland
    Posts
    44
    Thanks
    2
    Thanked 1 Time in 1 Post
    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

  • #4
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Post a little bit more code so the lines you posted previously are put in more context.
    OracleGuy

  • #5
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    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 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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •