XLL+ Class Library (7.0)

Creating optional arguments

In the previous section we took advantage of the fact that Excel passes zero for missing numeric arguments. Now we're going to use a more powerful technique for optional arguments: using the Function Wizard to change the argument type.

Change the argument type

Use the Tools/XLL+ Function Wizard menu to launch the Function Wizard. As before, make sure HISTVOL is selected.

In the arguments grid, go to the line containing DaysPerYear, and click on the Details tool-button, shown in red below.

This will bring up the Argument Details dialog. Put a check in the Optional checkbox.

This will enable the Default value groupbox. Enter 250.0 for the default value, as shown above, and click OK to save your changes.

Tip: To bring up the Argument Details dialog, you can also use the Argument/Details menu, or press Alt+Enter, or right-click the argument and use the context menu.

After you change the argument type, the Function Wizard should look like this:

Note that the Type column is now a little more interesting, and summarises everything the wizard knows about the argument thus: Double (=250.0)

Click on the OK button to dismiss the Wizard and update the source code.

Next: Reading an optional argument >>