Total Visual SourceBook

Total Visual SourceBook CD and Printed Manual

Microsoft Access/ Office 2016, 2013, 2010, and 2007 Version
is Shipping!

New features in Total Visual SourceBook for Access, Office 2007 and VB6

Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!

Separate version for Access/Office 2003, 2002, and 2000.

Separate version for:
Access 97/95


View all FMS products for Microsoft AccessAll Our Microsoft Access Products

SourceBook Info:

Why SourceBook?

 

"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."

Van T. Dinh, Microsoft MVP

 

 

 

Microsoft Access, Office/VBA, VB6 Modules royalty-free source code libraryMicrosoft Access Modules royalty-free source code libraryMicrosoft Access VBA and VB6 Module Library Free trial of Total Visual SourceBook for Microsoft Access, Office, VB6 and VBA

Class: ExpressionEvaluator in Category General VBA/VB6 : String Handling from Total Visual SourceBook

Class to implement expression evaluation in VBA and VB6.

Expression evaluation is a common need in many programs, especially if you deal with numbers and operators.

Procedure List

Procedure Name

Type

Description

(Declarations) Declarations Declarations and private variables for the CExpressionEvaluator class
Expression Property Get the expression to evaluate.
Postfix Property Get the postfix representation of the expression string
Class_Initialize Initialize Set initial values to defaults which may be overridden with property settings
Evaluate Method Evaluates the expression. For simplicity the postfix representation of the expression is evaluated.
CharType Private Determine the type of the current character
ConvertToPostfix Private Converts the expression to postfix and stores the result in m_strPostfix
GetNextToken Private Get the next token in the string identified by the text property
HandleSeparator Private Handles a separator character
HandleToken Private Handles a token character
HandleWhiteSpace Private Handles a whitespace character
ParseExpression Private Parses an expression
ParseFactor Private Parses a factor
ParseTerm Private Parse a term. A term is something like 2+7, or 1 + sin(1), while a token is the smallest meaningful piece of data, such as 2 or sin
PopResult Private Pops an item off the stack
PushResult Private Pushes an item onto the stack
SetTokenString Private Set the string used by the tokenizer

Example Code for Using Class: ExpressionEvaluator

' Example of CExpressionEvaluator
'
' To try this example, do the following:
' 1. Add a command button named 'cmdTest'
' 2. Paste all the code from this example to the new form's module.
' 3. Run the form

Private mExpressionEvaluator As CExpressionEvaluator

Private Sub cmdTest_Click()
  Dim dblResult As Double
  Set mExpressionEvaluator = New CExpressionEvaluator

  With mExpressionEvaluator
    .Expression = "5 * 10 / (12.5 * 2)"
    dblResult = .Evaluate
    Debug.Print "5 * 10 / (12.5 * 2) = " & dblResult
  End With

End Sub

Microsoft Access Module LibraryOverview of Total Visual SourceBook

The source code in Total Visual SourceBook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.

Additional Resources