Using string as a name of a variable

前端 未结 3 2063
走了就别回头了
走了就别回头了 2021-01-21 07:22

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         


        
3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-21 08:17

    I would like to share the code that I am using. Hope this helps future viewers of this question.

    Dim tb As TextBox = sender
    Dim tempObjNm As String
    tempObjNm =    tb.Name + "Strore"
    Me.GetType.GetField(tempObjNm).SetValue(Me, CType(mqtyCalc(someVariable.Text, Label1.Text), Double))
    

提交回复
热议问题