Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleEvaluate mathematical expressions using Excel's Evaluate function
Keywordsreplace, character, remove, unwanted
CategoriesUtilities, Strings
 
A previous example shows how to evaluate an expression by writing it into an Excel cell. Kent Finkle points out that you can use Excel's Evaluate function without even creating a worksheet.
 
Private Sub cmdEvaluate_Click()
Dim excel_app As Object

    Set excel_app = CreateObject("Excel.Application")

    ' Uncomment this line to make Excel visible.
'    excel_app.Visible = True

    ' Get the result.
    lblResult.Caption = _
        excel_app.Evaluate(txtExpression.Text)

    ' Comment the rest of the lines to keep
    ' Excel running so you can see it.

    ' Close Excel.
    excel_app.Quit
    Set excel_app = Nothing
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated