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 As Double
I will use that as a variables for storing value.
This function multiplies the number inside a label and textbox and returns a product.
Private Function mqtyCalc(ByVal y As Integer, ByVal z As Integer) As Integer
Dim w As Integer
w = y * z
Return w
End Function
This part handles three textbox events.
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged, TextBox2.TextChanged, TextBox3.TextChanged
Dim tb As TextBox = sender
Dim tempObjNm As String
tempObjNm = tb.Name + "Strore"
tempObjNm = mqtyCalc(someVariable.Text, Label1.Text)
End Sub
And this the part I'm trying to solve.
tempObjNm = someVariable.Name + "Strore"
tempObjNm = mqtyCalc(tb.Text, Label1.Text)
The "tempObjNm" is declared inside this sub as string.
Everytime I Input a value inside the textboxs, this sub will get the name of the textbox that has been inserted a value and the name will be added "Store" at their end Jus to mimic the variable name declared above. Example,
temObjNm = TextBox1Store (mimicking the Private TextBox1Store)
temObjNm is currently a string declared by
Dim tempObjNm As String
As a string
This part is the storing part of the sub
tempObjNm = mqtyCalc(tb.Text, 4)
(Take note that the value of tempObjNm = "TextBox1Store"
When I print TextBox1Store, it prints 0
How is that? Is it not possible to use a string for mimicking the varible just to store value in it?
When I print TextBox1Store, it prints 0What do you need to be printed while printing the variableTextBox1Store?mqtyCalc(someVariable.Text, Label1.Text). The.Textwould imply that those are strings, yet yourmqtyCalcmethod takes doubles. How can this even compile?