Private Sub cmdEvaluate_Click()
' #VBIDEUtils#************************************************************
' * Programmer Name : Waty Thierry
' * Web Site : www.geocities.com/ResearchTriangle/6311/
' * E-Mail : waty.thierry@usa.net
' * Date : 30/03/99
' * Time : 15:07
' * Module Name : ExcelEvaluation
' * Module Filename : Evaluate.frm
' * Procedure Name : cmdEvaluate_Click
' * Parameters :
' **********************************************************************
' * Comments : Evaluate mathematical expressions using Excel
' *
' *
' **********************************************************************
Dim excel_app As Object
Dim excel_sheet As Object
Set excel_app = CreateObject("Excel.Application")
' Uncomment this line to make Excel visible.
' excel_app.Visible = True
' Check for later versions.
excel_app.Workbooks.Add
If Val(excel_app.Application.Version) >= 8 Then
Set excel_sheet = excel_app.ActiveSheet
Else
Set excel_sheet = excel_app
End If
' Insert the equation.
excel_sheet.Cells(1, 1) = "=" & txtExpression.Text
' Get the result.
lblResult.Caption = excel_sheet.Cells(1, 1)
' Comment the rest of the lines to keep
' Excel running so you can see it.
' Close the workbook without saving.
excel_app.ActiveWorkbook.Close False
' Close Excel.
excel_app.Quit
Set excel_sheet = Nothing
Set excel_app = Nothing
End Sub