-2

I'm making a programme which has to evaluate function expressions like f(x) = x^2+6x-9, using Visual Basic (.NET).

I suppose the only way I can do this is by using NCalc, so I downloaded it and I can see that it is installed under 'Project > Manage NuGet Packages'. But I just don't have any idea what to do next. Do I have to declare something in my project before it can be used? Because now this still gives an error:

Dim e As Expression

Can someone help me?

Tim65
  • 1
  • 6

1 Answers1

0

Add an imports to the top of your file:

Imports Ncalc

Then you can use it as you described:

Dim x As New Expression("x^2+6*x-9")
x.Parameters.Add("x", "4")
Dim result = x.Evaluate
MessageBox.Show(result)
John Koerner
  • 37,428
  • 8
  • 84
  • 134