Hi Folks
I am writing an app in which I have a varaible number of instances of a class I need to instantiate. I have no problem creating a single instance by declaring a literal value as a new instance of the class. But what I want to do is create a for next loop that creates as many instances of the class as I need.
I have it in mind to do something like this:
Dim sObjNum As String
For Each drTrack In dtTrack.Rows
'create a new Track Object
sObjNum = "Tk" & Format(TkIncr, "00")
Public (sObjNum) As clsTrack
sObjNum.BlockID = drTrack.Item("BlockID").ToString()
...
TkIncr += 1
Next
...But as you can imagine VB does not like the variable in place of a literal value when naming the instance.
I know I'm going about this the wrong way, but I don't know what the right way is. Do I need to give each insrance a unique name? Can I just create them all with the same name (the properties will be different in each, with a unique set of values).
Can someone steer me in the right direction?
Thanks
CraigHartz
I am writing an app in which I have a varaible number of instances of a class I need to instantiate. I have no problem creating a single instance by declaring a literal value as a new instance of the class. But what I want to do is create a for next loop that creates as many instances of the class as I need.
I have it in mind to do something like this:
Dim sObjNum As String
For Each drTrack In dtTrack.Rows
'create a new Track Object
sObjNum = "Tk" & Format(TkIncr, "00")
Public (sObjNum) As clsTrack
sObjNum.BlockID = drTrack.Item("BlockID").ToString()
...
TkIncr += 1
Next
...But as you can imagine VB does not like the variable in place of a literal value when naming the instance.
I know I'm going about this the wrong way, but I don't know what the right way is. Do I need to give each insrance a unique name? Can I just create them all with the same name (the properties will be different in each, with a unique set of values).
Can someone steer me in the right direction?
Thanks
CraigHartz