help with array and functions

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

    help with array and functions

    Hi,
    I am wondering how i can pass an array as an optional parameter to a
    function?


  • Armin Zingler

    #2
    Re: help with array and functions

    "Brian S." <bsgallatin@com munity.nospamsc hrieb
    Hi,
    I am wondering how i can pass an array as an optional parameter to a
    function?
    Use the Optional keyword in the function signatur:

    Function Bla(Optional ByVal TheArray As String() = Nothing) _
    As Boolean


    End Function


    Instead of using optional parameters, you can also write overloaded
    functions.


    Armin

    Comment

    • Brian S.

      #3
      Re: help with array and functions

      when i try to evaluate TheArray.. i get the error
      ArgumentNullExc eption was unhandled.... Vaule cannot be null
      How can i evaluate this to determine if the user has passed an arrary to it
      or left it blank

      "Armin Zingler" <az.nospam@free net.dewrote in message
      news:enOQ0QtqIH A.5096@TK2MSFTN GP02.phx.gbl...
      "Brian S." <bsgallatin@com munity.nospamsc hrieb
      >Hi,
      >I am wondering how i can pass an array as an optional parameter to a
      >function?
      >
      Use the Optional keyword in the function signatur:
      >
      Function Bla(Optional ByVal TheArray As String() = Nothing) _
      As Boolean
      >
      >
      End Function
      >
      >
      Instead of using optional parameters, you can also write overloaded
      functions.
      >
      >
      Armin

      Comment

      • Armin Zingler

        #4
        Re: help with array and functions

        "Brian S." <bsgallatin@com munity.nospamsc hrieb
        > Function Bla(Optional ByVal TheArray As String() = Nothing) _
        > As Boolean
        >
        when i try to evaluate TheArray.. i get the error
        ArgumentNullExc eption was unhandled.... Vaule cannot be null
        How can i evaluate this to determine if the user has passed an
        arrary to it or left it blank
        "= Nothing" specifies the default value if the caller did not
        (explicitly) pass the parameter, so you just have to check this:

        If TheArray is Nothing Then
        'no parameter passed
        end if



        Armin

        Comment

        Working...