VB.NET equivalent of optional Range argument in VBA function

I have an Excel VBA function that takes several 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 was translating to VB.NET and this is the extra Range which gives me sadness because VB.NET does give extra ranges. Rather, additional parameters should contain a default value.

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

I have other compilation problems, so I was unable to study this. I think that accepting an optional object (the default is Nothing) might work, and then I can apply the object to the range. Alternatively, if a default was given that can be specified with an optional range, this would work too.

Any suggestions?

+2


source to share


1 answer


The default value for the optional Range parameter is Nothing:



+3


source







All Articles