I have a 25k record list of data that I want to bring into a class. Of the 25k records, there are 2500 records each belonging to one of 10 different things. The 10 things each have at least 1 unique property (an address in this case), and 2 other properties that may or may not be unique, but are tied to the individual thing.
I created a class (clsThing) that has 4 propertes:
Address
Prop1
Prop2
clsRecord
clsRecord has 6 different properties.
When I read the file in, I want to have only 10 clsThing objects, each with unique Address, Prop1, Prop2 and an array of clsRecord(s) which would be 2500 indexes. Something like this.
Address
Prop1
Prop2
clsRecord(2500)
F1
F2
F3
F4
F5
F6
Since I have spent the last 2 years in the uC world, I’ve lost some of the object oriented skills. Can anyone suggest the correct way to code this?
The most straightforward reading of your post indicates that you pretty much have the structure down, but you may be having trouble conceptualizing how to access the data. Your structure is really
Find the matching clsThing object (in an array?) or create a new one if needed.
Create a new clsRecord object and append it to the clsThing object’s clsRecord array.
To iterate over all the contents of the 25K records, you would have code like
for i = 0 to ubound(clsThingArray)
Address = clsThingArray(i).Address
Prop1 = clsThingArray(i).Prop1
Prop2 = clsThingArray(i).Prop2
for j = 0 to ubound(clsThingArray(i).clsRecordArray)
F1 = clsThingArray(i).clsRecordArray(j).F1
F2 = clsThingArray(i).clsRecordArray(j).F2
F3 = clsThingArray(i).clsRecordArray(j).F3
F4 = clsThingArray(i).clsRecordArray(j).F4
F5 = clsThingArray(i).clsRecordArray(j).F5
F6 = clsThingArray(i).clsRecordArray(j).F6
next j
next i
You should be able to Append to your clsRecordArray like:
dim objThing as clsThing
dim objRecord as clsRecord
objThing = ??? // obtain a valid clsThing object into objThing
objRecord = new clsRecord
objRecord.F1 = ??? // fill out the values
objThing.clsRecordArray.Append objRecord