tags:

views:

375

answers:

1

I have an Excel VBA function that takes a number of optional parameters, including an optional Range:

Function DazBeta(A As Range, Z As Range, _
        B As Integer, _
        Optional Freq As Integer = 1, _
        Optional c As Double = 0, _
        Optional r As Range, _
        Optional Pct As Boolean = True, _
        Optional Label As Integer = 1)

I am translating to VB.NET, and it's the optional Range that is giving me grief because VB.NET does allow optional Ranges. Or rather, optional parameters must provide a default value.

What is the recommended way to change the VB.NET function signature so that the code is callable from an Excel cell as a UDF? (The VB.NET implements a UDF, the assembly is registered as a COM server, and the Excel spreadsheet is told of this server and type library, allowing the VB.NET code to be called from an Excel spreadsheet cell.)

I have other compilation problems, so I have not been able to explore this. I am thinking that accepting an optional Object (default value Nothing) might work and then I could cast the Object to a Range. Alternatively, if there were a default value that could be specified with an optional Range, that would work, too.

Any suggestions?

+3  A: 

The default value for an optional Range parameter would be Nothing

Joe
So, totally not a problem. Wow, the shame.
hughdbrown