This should be what you’re looking for. This built-in function has its limits especially if the expression involves trigonometric functions but this should be enough for your needs.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
Dim answer = New DataTable().Compute(TextBox1.Text, Nothing)
MsgBox(answer)
Catch ex As Exception
MsgBox("Syntax Error")
End Try
End Sub
If you want a more challenging approach, which I recommend you would, you can create your own algorithm to manipulate strings and get numbers within to solve the expression. String manipulation functions should be what you’ll ever need such as Mid, Split, Contains, etc.
6
solved PEMDAS Visual Basic [closed]