问题描述
我正在创建用于计算物品重量的表格
我以字符串格式将公式存储到数据库中。
在计算的时候,我把这个公式带到我的表格中,我从用户那里获取价值。
公式是(val1-val2)* val2 * 0.00314 * val3
在用户输入后我更换了val1,val2&的值val3与用户输入
所以基本上我的公式就像(51-5)* 5 * 0.00314 * 4在这51,5,4是用户输入
我将此公式存储到标签
现在我想用这个公式来计算重量,所以我将标签值转换为双倍。
但它显示错误输入字符串的格式不正确。
任何人都可以帮助我。
我尝试过:
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
推荐答案
这篇关于如何使用标签文本中的公式进行计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!