FormulaCalculatorLib start page


FormulaCalculatorLib usage in VisualBasic

To use the functions exported from the FormulaCalculatorLib.dll you must declare the functions.
You may do it in this way:
Declare Function FormulaCalculatorLib_SetFormula Lib "FormulaCalculatorLib.dll" (ByVal formula_str$) As Long
Declare Function FormulaCalculatorLib_Calculate Lib "FormulaCalculatorLib.dll" (ByRef res As Double, ByVal arg_list$) As Long

Declare Function FormulaCalculatorLib_Reset Lib "FormulaCalculatorLib.dll" () As Long
Declare Function FormulaCalculatorLib_AddStatement Lib "FormulaCalculatorLib.dll" _
    (ByVal arg1$, ByVal arg2$, ByVal oper$, ByVal funct$, ByVal res$) As Long
Declare Function FormulaCalculatorLib_AddArgument Lib "FormulaCalculatorLib.dll" (ByVal name$, ByVal val_str$) As Long
Description of functions see here: FormulaCalculatorLib function reference

Then, after the declaration you may use the functions.
For example:
Private Sub butCalculate_Click()
    If (FormulaCalculatorLib_SetFormula(txtFormula) <> 1) Then
        MsgBox "Error during SetFormula", , "Error"
        Exit Sub
    End If
    
    Dim double_res As Double
    Dim arg_list$
    arg_list = Space(1000)
    If (FormulaCalculatorLib_Calculate(double_res, arg_list) <> 1) Then
        MsgBox "Error during ValidateArguments", , "Error"
        Exit Sub
    End If
    
    Dim str_arr$()
    str_arr = Split(arg_list, ",")
    
    Dim out_str$, i%
    If (UBound(str_arr) > 0) Then
        out_str = "Undefined arguments found:" + Chr(10) + Chr(13)
        For i = 0 To UBound(str_arr) - 1
            out_str = out_str + "Argument" + CStr(i + 1) + ": " + str_arr(i) + Chr(10) + Chr(13)
        Next i
    Else
        out_str = txtFormula + "=" + CStr(double_res)
    End If
        
    MsgBox out_str
End Sub
FormulaCalculatorLib usage in C/C++
www.maxdz.com
Rambler's Top100