0

Is there a function in VB.NET which can evaluate an arithematic string?

e.g., When passed 4+5-2 it should return the result (7).

cmcodes
  • 1,559
  • 19
  • 24

1 Answers1

1

Use DataTable:

Dim equation As String = "4+5-2"
Dim result = New DataTable().Compute(equation, Nothing)

Result is 7.

Gerrit
  • 804
  • 6
  • 18