-
October 26th, 2009, 12:04 PM
#1
VB6 Functions: Optional Parameters
How do I test for the presence of an option parameter with a function?
Example
Public Sub GridWrite(Grid As Control, FileName As String, Optional AnyForm As Form)
I want to see if the optional parameter "Anyform" was given by the calling form.
I tried:
if AnyForm.Name>"" then
' statements when parameter is given
endif
but I get an error 91: Object variable or With block variable not set.
Same thing with:
if AnyForm >'' then
If the optional parameter is an Integer, then a zero is given but when the parameter is a form, I get the error.
Thanks for your help
-
October 26th, 2009, 02:30 PM
#2
Re: VB6 Functions: Optional Parameters
You should rather check for Nothing. Something like this
Code:
Public Sub GridWrite(Grid As Control, FileName As String, Optional AnyForm As Form)
If Not AnyForm Is Nothing Then
'AnyForm was passed from the calling function
Else
'AnyForm was not passed from the calling function
End If
-
October 26th, 2009, 05:17 PM
#3
Re: VB6 Functions: Optional Parameters
Thank you Shuja Ali !!
Just what I needed.
ABasicNut
Tags for this Thread
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
|