Any way to pass an optional array?

  • Thread starter Thread starter Ryan
  • Start date Start date
R

Ryan

The code below gives me an error of "expression expected" at the first curly
brace. Thanks for any help.

Public Sub PopulateForm(Optional ByVal myID As Integer = -1, Optional ByVal
myRecipients() As Integer = {-1})
 
it doesnt like your arguement because its expecting a declaration with the
{}, so try changing it to this

Private Sub z(Optional ByVal arr() As Integer = Nothing)


hope that helps
 
Ryan said:
The code below gives me an error of "expression expected" at the first curly
brace. Thanks for any help.

Public Sub PopulateForm(Optional ByVal myID As Integer = -1, Optional ByVal
myRecipients() As Integer = {-1})


From the docs ('Parameter List'):

defaultvalue
Required for Optional parameters. Any constant or constant expression
that evaluates to the data type of the parameter. If the type is Object,
or a class, interface, array, or structure, the default value can only
be Nothing.
 
Back
Top