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).

4
  • 7
    Does this answer your question? Evaluate mathematical expression from a string using VB Commented Nov 23, 2019 at 12:58
  • That works for vb only! I need it for vb.NET Commented Nov 24, 2019 at 4:02
  • @cmcodes What are you talking about??? "works for vb only"??? Commented Nov 24, 2019 at 4:50
  • @Mary the Evaluate function mentioned by Alexandru Clonțea Commented Nov 24, 2019 at 16:55

1 Answer 1

1

Use DataTable:

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

Result is 7.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Man! It worked! Had to include Imports System.Data too! :)
Happy to help :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.