title: VB.NET equivalent of optional Range argument in VBA function
body: <p>I have an Excel VBA function that takes a number of optional parameters, including an optional Range:</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>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.</p>
  
  <p><strong>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?</strong> (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.)</p>
  
  <p>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.</p>
  
  <p>Any suggestions?</p>