textbox calculate expression
I have a question,
I want fill in a textbox for example 25 + 25
and in a label you can find the result 50
can anyone help me?
It really depends how complex you want the expressions to be.
Here's one solution:
Dim op1 As Integer = 25
Dim op2 As Integer = 25
Dim ans As Integer = op1 + op2
Textbox1.Text = op1 & " + " & op2
Label1.Text = ans.ToString()
I think the idea was that the user would type the expression into the TextBox and the app would parse it and display the result.
Originally Posted by Solitaire
If all you ever want to do is add two numbers then it's easy, but it becomes more and more difficult as you want to be able to use additional operators and longer expressions. Some the examples in the Google search I linked to will allow you to parse arbitrarily complex mathematical expressions.