Kuuchuu
Kuuchuu

Reputation: 436

Calculating multi-step math in a text box. - Visual Basic

I would like an application that I am creating in Visual Studio 2010 to be able to calculate a multi-step math problem that has been entered by the user into one whole text box.

The user would click a button, and the program would calculate the answer to the problem that they input. I was thinking something along the lines of:

Dim sngAnswer As Integer
sngAnswer = Val(Me.txtInput.Text)

But that doesn't work. Any ideas?

Upvotes: 2

Views: 2377

Answers (1)

Reed Copsey
Reed Copsey

Reputation: 564333

There is nothing included in the framework which will do this type of expression evaluation automatically.

You will likely want to use an expression parsing library to handle the math expression. NCalc and FLEE are both good options for this.

Upvotes: 1

Related Questions