Structures

sjn78

Well-known member
Joined
May 4, 2003
Messages
255
Location
Australia
I have a structure as follows

Structure Players
Dim Player1 as String
Dim Player2 as String
....... and so on
End Structure

If I now define a new object using this structure, is there a way to query through each of its children eg,

Dim Team as New Players()
Dim i as Integer = 1

Some code to find Team.Players1 since i = 1 but if i = 2, then use Team.Players2.

Then I can jump to a function specific to what player is current.

Team.Player?? (the one that matches to i) then do something else.


The way I am thinking about this is the same way you would loop through all of the controls on a form and look for a match in the controls name or text.

I know I could do it with a Select Case or If statements, but I am trying to do it without having to code a few hundreds lines.

Thanks

Steve
 
I thought about that and will most likely go that way, but can you still do what I asked in the previous post??
 
You could probably use reflection to build up a string of "Player1" and find the actual property, but I dont think its a very good design. There are SO many other, better options. A hashtable, for instance, allows storing data and finding it by a string name.

If you really want to find a control by "name" (meaning, the string translates into the actual control name) it can be done. For finding fields in a struct, I would think this is a last resort.

-nerseus
 
Back
Top