Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Optional Byte Array Parameter

Posted on 2002-07-10
5
Medium Priority
?
460 Views
Last Modified: 2008-03-06
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

0
Comment
Question by:bryker
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 23

Accepted Solution

by:
naveenkohli earned 400 total points
ID: 7143760
This is by rule that you can only supply contant values for optional arguments. You can't use "new" operator in the argument definition. You should be able to set this array argument to "null" by default. And then in function call you will check if this argument value is null or not.
0
 
LVL 10

Expert Comment

by:GoodJun
ID: 7143788
tried
Optional ByRef ByteArrayData() As Byte =nothing
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 7143844
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)?
0
 

Author Comment

by:bryker
ID: 7143848
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.
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 7143852
And have you tried:

Optional ByRef ByteArrayData() As Byte = Nothing
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question