Text box as math expression

  • Thread starter Thread starter Andrew Elmore
  • Start date Start date
A

Andrew Elmore

How can in read the values of a textbox and translate it to a math equation?
like the calc. When the box validates if there is a decimal it rejects it
and goes back to what it was (e.cancel) How can I get this to work?

1+1+1-1*3/2

Thanks,
Andy
 
* "Andrew Elmore said:
How can in read the values of a textbox and translate it to a math equation?
like the calc. When the box validates if there is a decimal it rejects it
and goes back to what it was (e.cancel) How can I get this to work?

1+1+1-1*3/2

Use 'Double.TryParse' to check if the text in a textbox can be converted
to a number.

If you want to evaluate a mathematical expression contained in a string,
have a look at this C# library:

<http://www.palmbytes.de/content/dotnet/mathlib.htm>
 
This solution does not work using Double.Parse.

There are several links out on the net about this, But I have not been able
to find one which does the job really. I saw a thread earlier about three
weeks ago where someone had very cleverly used a compiled javascript object
library declared in VB.NET to use that function. Have a look in this
newsgroup.

Regards - OHM

Use 'Double.TryParse' to check if the text in a textbox can be
converted to a number.

If you want to evaluate a mathematical expression contained in a
string, have a look at this C# library:

<http://www.palmbytes.de/content/dotnet/mathlib.htm>

Regards - OHM# (e-mail address removed)
 
* "One Handed Man said:
This solution does not work using Double.Parse.

ACK. It cannot be used to evaluate an expression. I was not sure if
the OP wanted to build the expression string from input given in
multiple textboxes or if the user should input everything into a single
textbox.
 
Back
Top