VBA & VB6 Interface |
![]() |
The VBA/VB6 interface allows two different types of applications.
These functions are only available in ARulesXL Add-in for Excel:
The standard ARulesXL API functions are available outside of the add-in:
Description:
Function VBARQuery( RuleSet As Range, QueryText As String, ParamArray Cell_1_to_N() As Variant) As Variant
Remarks:
Queries the named ruleset and returns the result.
Return Value:
The result of the query, which can be an integer, floating point number, string or array. You can use the RANGE() function in your rules to return where your RArray() and RCell() data are located.
Returns an error message on failure.
Example:
Set rules = Range("BudgetRules")
' This is a simple example picking up a dimension to highlight
' from the rule.
result = Application.Run("ARulesXL.xla!VBARQuery", rules, "FIND HighLight")
Range(result).Interior.ColorIndex = 3
Description:
Function VBARQueryMore( RuleSet As Range, QueryText As String, ParamArray Cell_1_to_N() As Variant) As Variant
Remarks:
Queries the named ruleset using results derived during prior queries and returns the result.
Return Value:
The result of the query, which can be an integer, floating point number, string or array. You can use the RANGE() function in your rules to return where your RArray() and RCell() data are located.
Returns an error message on failure.
Example:
Set rules = Range("BudgetRules")
' This is a simple example picking up a dimension to highlight
' from the rule.
result = Application.Run("ARulesXL.xla!VBARQueryMore", rules, "FIND HighLight")
Range(result).Interior.ColorIndex = 3
Description:
Function RArrayQuery( RuleSet As Range, First As Boolean, QueryText As String, ParamArray Cell_1_to_N() As Variant) As Variant
Remarks:
Queries the named ruleset and returns the result as a VBA array. You can call VBARQuery() just a from a cell, and it returns a variant. But, VBARQuery() doesn't know whether to format arrays as strings or arrays when called from VBA. So you can call VBARArrayQuery(), just like VBARQuery(), and know that it will return arrays formatted as arrays.
Return Value:
The result of the query as a VBA array.
Returns an error message on failure.
Example:
' Pick up the range of the rule set.
Set rules = Range("BudgetRules")
' The second boolean argument is whether or not this is a first time query
' or will use derived results from a previous query.
result = Application.Run("ARulesXL.xla!VBARArrayQuery", rules, True, "FIND analysis")
' Since we expect an array, a string is an error message.
vt = VarType(result)
If vt = vbString Then
MsgBox "Error: " & result
Else
' The array contains the cells and comments indicating problems. Annotate
' the spreadsheet with each.
For i = LBound(result) To UBound(result)
Range(result(i, 1)).Interior.Color = vbYellow
Range(result(i, 1)).AddComment (result(i, 2))
Next i
End If
The VB6/VBA interface to the Amzi! Logic Server is part of the ARulesXL add-in. You can call the procedures and functions in that interface as documented in the Amzi! Logic Server Reference Guide.
Open the 'Budget Analysis.xls' sample spreadsheet. A 'Budgets' menu will appear in Excel. You can use it to run the analyses. To see how the commands are implemented, use Tools | Macro | Visual Basic Editor to open the PLFunctions Module.
In order to run this sample:
|
Copyright ©2005-7 Amzi! inc. All Rights Reserved.
|