|
-
Mar 6th, 2006, 07:06 AM
#1
Thread Starter
Hyperactive Member
[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
-
Mar 6th, 2006, 07:07 AM
#2
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.. )
I code C#....

-
Mar 6th, 2006, 07:09 AM
#3
Re: When declairing an optional argument
 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.
-
Mar 6th, 2006, 07:23 AM
#4
Frenzied Member
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
oh1mie/Vic

-
Mar 6th, 2006, 07:24 AM
#5
Thread Starter
Hyperactive Member
Re: When declairing an optional argument
You must spread some Reputation around before giving it to Hack again. 
Thanks guys.
-
Mar 6th, 2006, 07:25 AM
#6
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|