VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Evaluate mathematical expressions using Excel

by Waty Thierry (60 Submissions)
Category: Windows System Services
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Tue 13th April 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Evaluate mathematical expressions using Excel

Rate Evaluate mathematical expressions using Excel



   ' #VBIDEUtils#************************************************************
   ' * Programmer Name  : Waty Thierry
   ' * Web Site         : www.geocities.com/ResearchTriangle/6311/
   ' * E-Mail           : [email protected]
   ' * 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



Download this snippet    Add to My Saved Code

Evaluate mathematical expressions using Excel Comments

No comments have been posted about Evaluate mathematical expressions using Excel. Why not be the first to post a comment about Evaluate mathematical expressions using Excel.

Post your comment

Subject:
Message:
0/1000 characters