Visual Basic 6


Adding uCalc Fast Math Parser to your VB application


In order to implement uCalc Fast Math Parser in Visual Basic 5 or 6, follow these steps:


  1. Copy uCalcVB.Bas to your project directory, or an appropriate include directory.
  2. Place ucFMP315.dll and uCalcLBx.dll either in the Windows System directory, your project directory, or any suitable directory that is in the path.
  3. From the VB menu, select Project Add Module.  Click on the Existing tab, and add uCalcVB.Bas.


Now you're all set to go.


If you want to avoid getting Run-time error '53': "File not found: ucFMP315.dll" when you are running your program from the IDE, go to Project / Properties... from the menu.  Then in the Startup Object section, select Sub Main.  Then add this code to a separate module:


' This code isn't necessary if the DLLs are in the Windows\System32 directory

' or if you run the .EXE outside the IDE while the DLLs are in the application's path.

Sub Main()

  ChDir App.Path

  Form1.Show ' you may need to replace Form1 with the name of the opening form.

End Sub


Demo program


The name of the uCalc demo project file to load up in VB is DemoVB.vbp.  The source code in the project demonstrates the essential features, especially as they relate to VB.  DemoVB.Bas contains the code for uCalc callback functions, and DemoVB.Frm contains calls to uCalc routines.





VB Examples:


Example 1:  Simple ucEval example

Example 2:  Simple evaluation with ucEvalStr

Example 3:  Fast evaluation millions of times in a loop

Example 4:  Error handling with ucError

Example 5:  Defining a centralized error handler

Example 6:  Using ucResume to allow auto variable definitions

Example 7:  Raising an error with ucRaiseErrorMessage

Example 8:  Raising an error in an expression

Example 9:  Division by 0 vs Inf

Example 10:  Overflow vs Inf

Example 11:  Invalid Op vs NaN

Example 12:  Thread handling

Example 13:  Trig mode

Example 14:  ucDefine

Example 15:  Miscellaneous self-contained function definitions

Example 16:  Bootstrapping a function definition

Example 17:  A native function callback with two numeric arguments

Example 18:  A native function callback with any number of arguments

Example 19:  A native string callback function

Example 20:  Native function callback ByExpr arguments

Example 21:  Native function callback ByHandle argument

Example 22:  A non-native function callback

Example 23:  Strings in non-native functions

Example 24:  Non-native function callback with ByExpr arguments

Example 25:  Miscellaneous self-contained operator definitions

Example 26:  Non-native operator callback definition

Example 27:  Native operator callback definition

Example 28:  Miscellaneous syntax constructs

Example 29:  ucExpand

Example 30:  Creating an RPN calculator

Example 31:  Self-contained variables

Example 32:  Attached variables

Example 33:  Attaching array variables

Example 34:  Localized variables

Example 35:  Local variable, and ByHandle argument (Summation)

Example 36:  Local variable, and ByHandle argument (Equation Solver)

Example 37:  Using ucArg with a function definition

Example 38:  Using ucArg with an operator definition

Example 39:  Using ucArgStr for a string argument

Example 40:  ucArgCount