PDA

Click to See Complete Forum and Search --> : Evaluator


Arne Elster
Jan 20th, 2007, 05:45 PM
Hi,

this is a simple expression evaluator.
You can input a term like "1+1" or "(3**4=3^4)+log(100,10)-cos(2*Pi)*2"
and it will calculate it for you.
Supports simple operators ( + - * / ^ < > <> = ), brackets, variables and functions with any number of parameters.

Using the class in your code is very easy.
This example will print the first 10 powers of 2.
Dim clsEval As New Evaluator

clsEval.AddVariable "x", 0

If clsEval.Parse("2^x") Then
For i = 0 To 9
clsEval.VariableValue("x") = i
Debug.Print clsEval.Evaluate()
Next
Else
MsgBox "Error while parsing!"
End If