I was creating Form for calculating weight of item
I was stored formula to database in string format.
While calculating i was take that formula to label in my form and i am taking value from user.
the Formula is "(val1-val2)*val2*0.00314*val3"
after taking user input i was replace the value of val1, val2 & val3 with user input
so basically my formula is like "(51-5)*5*0.00314*4" in this 51,5,4 is user inputs
and i am store this formula to label
now i want to use that formula for calculating weight, so i am convert label value to double.
But it shows me error "input string is not in correct format."
Can anyone help me.
What I have tried:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim bindformula As String = lblActualFormula.Text
bindformula = bindformula.Replace("Val1", txtOd.Text)
bindformula = bindformula.Replace("Val2", txtWT.Text)
bindformula = bindformula.Replace("Val3", txtLength.Text)
lblBindFormula.Text = bindformula
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim val As Double = Double.Parse(lblBindFormula.Text)
MsgBox(val.ToString())
End Sub