Link to home
Start Free TrialLog in
Avatar of bryker
bryker

asked on

Optional Byte Array Parameter

I canNOT get this right.  I just want my first parameter to be an optional byte array.  The most recent code I've tried is below, and the syntax error I get is "Constant expression is required".

How the heck do I supply a default value for this optional byte array, so that it's an empty byte array by default?  (Ubound(a) = 0, or better yet, Ubound(a) < 0)?

Thanks a bunch.

   Private Function StartXMLDecompressorThread( _
      Optional ByRef ByteArrayData() As Byte = New Byte() {}, _
      Optional ByVal sEXEPath As String = "", _
      Optional ByVal sXMLPath As String = "", _
      Optional ByVal sOutputPath As String = "" _
      ) _
      As Integer

ASKER CERTIFIED SOLUTION
Avatar of naveenkohli
naveenkohli

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GoodJun
GoodJun

tried
Optional ByRef ByteArrayData() As Byte =nothing
Did you ever consider altering this to be an overloaded function?  Or is it just too many optional arguments to consider (maybe rework it a bit)?
Avatar of bryker

ASKER

Man, do I feel like an idiot.  I keep forgetting that EVERYTHING in .NET is an object, and so can be legitimately set to Nothing.

Thanks for the help.
And have you tried:

Optional ByRef ByteArrayData() As Byte = Nothing