Evaluate mathematical expression from a string using VB

前端 未结 3 563
小蘑菇
小蘑菇 2020-12-02 00:03

I want to calculate a arithmetic expression from a string using VB, any ideas ?

As an example : \"x+2\" from a textbox, I want to evaluate the expression

3条回答
  •  [愿得一人]
    2020-12-02 00:40

    Dim equation As String = "2+6/2"
    Dim result = New DataTable().Compute(equation, Nothing)
    

提交回复
热议问题