Create a hash table:
\n Public htFieldAddrMap As New Hashtable\n
Fill it with the control file keys and the actual
objects.
Note: I forgot to name the object with the type
prefix. I saw a chunk of code, was reminded, and
then started doing it. I didn't go back and
fix the ones I already did.
I hate the VB Editor. I've exported the form into
a flat file so I can clean it up in gvim later.
\n htFieldAddrMap.Add("JOB", Me.job)\n htFieldAddrMap.Add("PROJECT", Me.Project)\n htFieldAddrMap.Add("CLEAR_LOCKS", Me.ClearLocks)\n htFieldAddrMap.Add("PNT_WFD", Me.WFD_File)\n
This list goes on for about a 40 fields and objects.
Different types. But I only have one list type, which
I handle in hard code later.
I read the control file via:
\n Dim arr() As String = Split(line, "=")\n arr(0) = arr(0).Trim()\n arr(1) = arr(1).Trim()\n\n If htFieldAddrMap.ContainsKey(arr(0)) Then\n Dim type = htFieldAddrMap(arr(0)).GetType().ToString\n\n Select Case type\n Case "System.Windows.Forms.TextBox"\n htFieldAddrMap(arr(0)).text = arr(1)\n Case "System.Windows.Forms.CheckBox"\n htFieldAddrMap(arr(0)).checked = arr(1)\n Case "System.Windows.Forms.NumericUpDown"\n htFieldAddrMap(arr(0)).value = arr(1)\n Case "System.Windows.Forms.ComboBox"\n htFieldAddrMap(arr(0)).text = arr(1)\n Case Else\n MsgBox("Unhandled Type:" & arr(0) & "]:[" & type & "]")\n End Select\n\n
I basically do the reverse when writing, converting booleans
to 1/0 since my later code wants it that way.