T
Tomas
A newbie question: How can I instantiate objects dynamically in
VB.NET. E.g. I have the object 'Player' and I would like to
instantiate it with the several instances (James, Gunner, etc.),
without in advance knowing how many objects (employee1, employee2,
etc)
Dim player1 As New Persons.Players
Dim player2 As New Persons.Players
Dim player3 As New Persons.Players
....
With player1
.FirstName = "Andrew"
.LastName = "Cencini"
.Number = 43
.Position = "Shortstop"
End With
With player2
.FirstName = "Robert"
.LastName = "Lyon"
.Number = 11
.Position = "Catcher"
End With
....
I would like to instantiate a number of players (user decide the
amount) dynamically during program run. Like a loop where the user can
chose to instantiate 5, 50, or 100 players. Something like this....
For n=0 to 100
Player_number = "player" & n
Dim Player_number As New Persons.Players
Next
How would I do this in VB.NET?
Very grateful for any pointers,
Tomas
PS" I might not use the correct vocabulary, but I hope my question is
clear enough."
VB.NET. E.g. I have the object 'Player' and I would like to
instantiate it with the several instances (James, Gunner, etc.),
without in advance knowing how many objects (employee1, employee2,
etc)
Dim player1 As New Persons.Players
Dim player2 As New Persons.Players
Dim player3 As New Persons.Players
....
With player1
.FirstName = "Andrew"
.LastName = "Cencini"
.Number = 43
.Position = "Shortstop"
End With
With player2
.FirstName = "Robert"
.LastName = "Lyon"
.Number = 11
.Position = "Catcher"
End With
....
I would like to instantiate a number of players (user decide the
amount) dynamically during program run. Like a loop where the user can
chose to instantiate 5, 50, or 100 players. Something like this....
For n=0 to 100
Player_number = "player" & n
Dim Player_number As New Persons.Players
Next
How would I do this in VB.NET?
Very grateful for any pointers,
Tomas
PS" I might not use the correct vocabulary, but I hope my question is
clear enough."