Results 1 to 2 of 2

Thread: An array, collection, or object??? Need help!

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    Cliffwood Beach, NJ, USA
    Posts
    6

    Post

    I am writing an app that will load a matrix of accounts and document types from a detail file which may contain many accounts and many documents of the same type for each account. Basically all this will be loaded into a treeview with each account showing up only once as a parent, then each document type (only once) under that, and finally every document record read, stored uder the correct account and document type. So for example, I may have some raw data that may come in like this:

    Account#, DocType, Date created
    55555555, 2, 2/2/00
    22222222, 1, 1/31/99
    33333333, 1, 1/25/00
    55555555, 2, 12/31/99
    55555555, 2, 2/1/00
    55555555, 1, 11/30/98

    The ultimate goal would be to have the tree something like this:

    22222222
    ---1
    ------1/31/99
    33333333
    ---1
    ------1/25/00
    55555555
    ---1
    ------11/30/98
    ---2
    ------12/31/99
    ------2/1/00
    ------2/2/00

    So I am looking for the proper way to store this stuff so A)I can properly load the treeview without adding duplicates and B)so I can access the data at the document level (I simplifed this example, for the purposes of asking for help).

    At first I thought I could use a multidimensional array. I would have a single dimension array with just accounts in it and search that array first to see what index a particular account is in. I would use the 2nd dimension to hold the document type. Problem is I don't know ahead of time if I will have 1 or 100 document types for a particular account and I don't want to make a big fixed size array and waste alot of memory.

    What I really have here or would like I suppose is an array inside an array. In this approach I would have the account array holding the document type array (which could be a different size for each account).

    So my actual question here is how would you implement this situation? I suppose the easiest would be to declare a large multi-dim array, but I wonder if I could use a collection or several collections, or even better, an object. I don't know much about objects yet but maybe there is some way to create one object for each account. I could still have my account array to determine if I 'have' that account already and if not create a new object with it's own array. Even with this approach however, how would I get down to that level, the array within the particular object when desired?

    Thanks for taking the time to read all this and I hope you can help me find a solution!

  2. #2
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600

    Post Maybe a Start.

    Hi mskvarenina.

    You can use a dynamic array if you want to use an array but avoid this problem:

    I don't want to make a big fixed size array and waste alot of memory.
    Here's an example:
    Code:
        Dim myArray() As String
        
        ReDim Preserve myArray(15) 'Assign 16 elements to the Array
    I hope that this little example helps.

Posting Permissions

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



Click Here to Expand Forum to Full Width