[RESOLVED] When declairing an optional argument
Is there a way to tell if the arguemnt was passed or not?
VB Code:
Sub LoadConfiguration(ByVal ConfigurationFile As String, _
ByRef ConfigurationCollection As Collection, _
Optional ByRef KeyCollection As Collection)
If KeyCollection Then: MsgBox "twas passed" '?
End Sub
Re: When declairing an optional argument
Can't you check if KeyCollection <> empty?
(Don't have VB 6 here so can't test if that works.. )
Re: When declairing an optional argument
Quote:
Originally Posted by vbcode1980
Can't you check if KeyCollection <> empty?
(Don't have VB 6 here so can't test if that works.. )
Exactly right.
Just do a quick If to see if that value has anything in it.
Re: When declairing an optional argument
VB Code:
Sub LoadConfiguration(ByVal ConfigurationFile As String, _
ByRef ConfigurationCollection As Collection, _
Optional ByRef KeyCollection As Collection = Nothing)
If KeyCollection Is Nothing Then
MsgBox "not passed"
Else
MsgBox "twas passed"
End If
End Sub
Re: When declairing an optional argument
You must spread some Reputation around before giving it to Hack again. :(
Thanks guys.
Re: When declairing an optional argument
Empty works only for Variants.
You have to check for Nothing.
VB Code:
If Not KeyCollection Is Nothing Then: MsgBox "It was passed"
EDIT: oh1mie, you have beaten me