in a textbox am having text as
"(20/100)+pay1*pay2" .it's a formula. and stored in a particular
variable.
string strformula="(20/100)+pay1*pay2" ;
i've to substitute the value of the variable 'pay1' & 'pay2' and
finding the value of that strformula.
can any onr tell me how to find 'pay1' and 'pay2' in the variable
strformula. it's urgent and reply immediately.
Thanks in advance.
in a textbox am having text as
"(20/100)+pay1*pay2" .it's a formula. and stored in a particular
variable.
string strformula="(20/100)+pay1*pay2" ;
i've to substitute the value of the variable 'pay1' & 'pay2' and
finding the value of that strformula.
can any onr tell me how to find 'pay1' and 'pay2' in the variable
strformula. it's urgent and reply immediately.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim pay1 As Double, pay2 As Double
Dim MySrc As String
pay1 = 2323.56
pay2 = 4354.56
MySrc = TextBox1.Text
MySrc = Replace(MySrc, "pay1", pay1.ToString)
MySrc = Replace(MySrc, "pay2", pay2.ToString)
TextBox2.Text = MySrc
End Sub
will do the replacement. However calculating the value is a whole other
ballgame. This is "evaluating the expression" and is a well known problem in
computer science. It is not trivial. Why don't you use Excel instead?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.