For some time I have been wondering if it is possible to enumerate, or set and index for the properties of an object or structure.
I currently have a set of custom graph generator classes for different reports, but they all accept the same structure as a parameter.
The structures' properties' values get set from a SQL reader that reads columns as they are set up in a table in the database. Now ideally want to loop though these column values sequentially and write them to the properties of the structure.
My Structure is as follows:
Public Structure MyStructure
Dim GraphName As String
Dim GraphValue As Integer
Dim Red As Integer
Dim Green As Integer
Dim Blue As Integer
End Structure
Now I want to be able to loop through these properties and assign values to each. E.g.:
Dim Struct as MyStructure
For i as integer = 0 to 4
Struct.i = "A value retrieved from database"
Next i
The main idea is that i want to avoid using a case statement:
Dim Struct as MyStruct
For i as integer = 0 to 4
Select Case i
Case 0
Struct.GraphName = "A value retrieved from database"
Case 1
Struct.GraphValue = "A value retrieved from database"
'Etc.
End Select
Next i
Any insight on this will be much appreciated.