The formula wizard and its features are among the most important and powerful capabilities of the Designer. Using a special List & Label component for the OCX, you can also integrate fully customized functions into the Designer. To use the control, you must include the file cmll30fx.ocx in your IDE.
To add a new function, insert this component on a form at the time of design. You can now set the necessary parameters in the Properties window of this component.
Property |
Description |
Name |
The unique name of the designer function. |
Description |
An additional description of the function for the formula wizard. |
GroupName |
The group in which the function is displayed in the formula wizard. |
Visible |
Indicates whether or not the function will be displayed in the wizard. |
MinimumParameters |
The minimum number of parameters. Permissible values between 0 and 4. |
MaximumParameters |
The maximum number of parameters. Here too, permissible values between 0 and 4. The value must be equal to or greater than the minimum number. Increasing the number results in optional parameters. |
ResultType |
The data type of the return value. |
Using the properties, you can customize the configuration of the new Designer function. The parameters for the design functions are defined in the source code. This may look as follows:
Visual Basic:
Private Sub InitializeDesFunction()
Dim param1 As DesignerFunctionsParameter
Dim param2 As DesignerFunctionsParameter
Set param1 =
DesFunc_Add.Parameter1
param1.Description = "First Value"
param1.Type =
LlParamType.ParamType_Double
Set param2 =
DesFunc_Add.Parameter2
param2.Description = "Second Value"
param2.Type =
LlParamType.ParamType_Double
DesFunc_Add.ParentComponent =
ListLabel1
End Sub
In order to bring the function to life, you have to handle the event DesFunc_Add_EvaluateFunction. Using the event arguments, you gain access to the parameters entered by the user. For example, to return the sum of the two parameters, use the following lines:
Visual Basic:
Private Sub
DesFunc_Add_EvaluateFunction(ResultValue As Variant,
ResultType As CMLL30FXLibCtl.LlParamType,
DecimalPositions As Long,
ByVal Parameters As Long, ByVal Parameter1 As Variant,
ByVal Parameter2 As Variant, ByVal Parameter3 As Variant,
ByVal Parameter4 As Variant)
ResultValue = CDbl(Parameter1) +
CDbl(Parameter2)
ResultType =
ParamType_Double
End Sub
Two additional events also give you the option to further modify the function. DesFunc_Add_CheckFunctionSyntax lets you perform a syntax check. Here you can check the data types of the parameters and, for example, make sure the parameters fall within a certain range. DesFunc_Add_ParameterAutoComplete allows you to define several suggested values for the AutoComplete feature of the formula wizard.