XLL+ Class Library

Using COper for 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 to a COper.

Change the argument type

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

In the arguments grid, go to the Dimensions column of the line containing DaysPerYear, and click on the prompt (...) button, or the Edit argument tool-button, as shown below.

This will bring up the Edit Argument dialog. Select the General tab, as shown below, and set the value of the Optional combo to "Optional".

This will show the Default value field. Enter 250.0 for the default value, as shown below, and click OK to save your changes.

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

Note that the Dimensions column is now a little more interesting, and summarises everything the wizard knows about the argument thus: Optional Scalar [250.0]

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

Next: Reading an optional argument >>