help with array and functions

  • Thread starter Thread starter Brian S.
  • Start date Start date
Brian S. said:
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
 
when i try to evaluate TheArray.. i get the error
ArgumentNullException 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
 
Brian S. said:
when i try to evaluate TheArray.. i get the error
ArgumentNullException 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
 
Back
Top