Is it possible to use a string as a name of a variable? For Example..
I declared x as a private double
Private TextBox1Store,TextBox2Store,TextBox3Store A
Can you use a Dictionary(Of String, Double)?
Private values As New Dictionary(Of String, Double)
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
setValue(sender)
End Sub
Private Sub setValue(sender As Object)
Dim tb As TextBox = CType(sender, TextBox)
Dim tbName As String = tb.Name & "Strore"
If Not values.ContainsKey(tbName) Then
values.Add(tbName, tb.Text)
Else
values(tbName) = tb.Text
End If
End Sub
Private Function getValue(sender As Object) As Double
Dim tbName As String = CType(sender, TextBox).Name & "Strore"
If Not values.ContainsKey(tbName) Then
Return Double.NaN
Else
Return values(tbName)
End If
End Function