+ Reply to Thread
Results 1 to 3 of 3

data storage

  1. #1
    Registered User
    Join Date
    09-19-2011
    Location
    oc,ca
    MS-Off Ver
    Excel 2003
    Posts
    44

    data storage

    I have a 10 element array named "people" and it contains the name of 10 different people. Each element of the array "people" has an unknown # of attributes.

    My question is what are some ways I can store the attributes of each name so that they are linked to the corresponding name in the array?

    Currently, I joined the attributes in a single string and then split them into an array when I need to use them. For example


    People(0)="John"
    Attribute1(0)="male , 44 yrs old, white, single"
    AttributeArray=Split("Attribute1(0)", ",", , vbTextCompare)


    Is there a better way?

  2. #2
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: data storage

    why not just a two-dimensional array compared to using a jagged array
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: data storage

    This would be a perfect application of custom classes.
    You would want two custom objects:
    clsPerson has the properties of Name, Age, Gender, MaritalStatus and Race
    clsPeople has a collection of clsPerson's, called Persons; a property Count, and a function Add

    in a class module (named clsPerson) put

    Please Login or Register  to view this content.
    in the class module clsPeople:

    Please Login or Register  to view this content.
    And it could be used with code like this (in a normal module)
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1