I have a large structure (50+ members) like this:
Public Structure DagDay
Public DayDate As Date
Public DayEcoZone As String
Public DayOrd As Boolean
Public DayHelg As Boolean
Public DayAfton As Boolean
Public DayEvent As Boolean
Public DayEventText As String
Public DayIncVat As Boolean
Public DayOmsTot As Integer
Public DayOmsCat1 As Integer
Public DayOmsCat2 As Integer
Public DayOmsCat3 As Integer
.....
End Structure
...
Dim ThisDay as DagDay
Now i'm trying to let a function set any specific members value in in the variable ThisDay, but I can't figure out how (else then a large select.. Case..).
Public Function SetValue(ByVal Field As String, ByVal value As VariantType) As Boolean
Select Case Field
Case "DayDate"
ThisDay.DayDate = value
Case "DayEcoZone"
ThisDay.DayEcoZone = value
Case "DayOrd"
ThisDay.DayOrd = value
Case "DayHelg"
ThisDay.DayHelg = value
.....
End Select
I would like to be able to do something like this (pseudo code):
Public Function SetValue(ByVal Field As String, ByVal value As VariantType) As Boolean
ThisDay.[Field] = value
Return True
End Function
How can I use a string variable to reference a specific member (field) in a structure?
VariantType?Fieldthat you pass in?Fieldcomes from the name-property of corresponding input field (TextBoxorCheckBox):es-controls that are dynamically created in one of three differentForms.