Results 1 to 1 of 1

Thread: Evaluator

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2006
    Posts
    46

    Evaluator

    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.
    Code:
    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
    Attached Files Attached Files
    Last edited by Arne Elster; Jan 21st, 2007 at 10:00 AM. Reason: fixed a sign error

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width