Any way to pass an optional array?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ryan

    #1

    Any way to pass an optional array?

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

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




  • iwdu15

    #2
    RE: Any way to pass an optional array?

    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

    --
    -iwdu15

    Comment

    • Larry Lard

      #3
      Re: Any way to pass an optional array?

      Ryan wrote:
      The code below gives me an error of "expression expected" at the first curly
      brace. Thanks for any help.
      >
      Public Sub PopulateForm(Op tional 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.



      --
      Larry Lard
      larrylard@googl email.com
      The address is real, but unread - please reply to the group
      For VB and C# questions - tell us which version

      Comment

      • Ryan

        #4
        Re: Any way to pass an optional array?

        That does the trick. Thanks.


        "iwdu15" <jmmgoalsteraty ahoodotcomwrote in message
        news:59186B6A-43D9-41F9-B3E5-87B8D11E511F@mi crosoft.com...
        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
        >
        --
        -iwdu15

        Comment

        Working...