How can I "convert" a number to a variable name ?
Ok, so I receive from an external source over network, a number and a value. There are aprox 600 numbers. So now I need to put that value into a variable in my program. I could do with a long select-case where I look up the number, then store the sent value in the corresponding variable. Or, is there any other way ? Like storing all variable names in an array in the position that corresponds with the number, then get the var name from the array and set the received value to that variable ?
Sub WriteToMyVars(varNumber, val)
Select varNumber
Case "100"
MyVarName1 = val
Case "101"
MyVarName2 = val
Case "102"
MyVarName3 = val
'etc etc
End Select
End Sub
'or -----------------------------------
Dim a(600) As String
a(100) = "MyVarName1"
a(101) = "MyVarName2"
a(102) = "MyVarName2"
'etc etc
Sub WriteToMyVars(varNumber, val)
a(varNumber) = val 'this won't work I know, it'll put the val in the array instead of the varname, but something like this would be way shorter than the above
End Sub