-
Hi,
On my form I have a image control Image1 and picturebox control Picture1.
I seem to have trouble with 'Optional' keyword and IsMissing() intristic function.
As I understand it, when I declare a sub with an 'Optional argument',
I don't have to pass that variable at all. Then I can use IsMissing() function
to check if the argument was passed or not.
But that doesn't work. Whenever I use (see code below):
MySub Image1
----- or -----
MySub Image1, Picture1
I get the same results "Picture box is included"
CODE:
'-----------------------------------------------------------
Private Sub MySub(img As Image, Optional pic As PictureBox)
If IsMissing(pic) Then
MsgBox "PictureBox is missing"
Else
MsgBox "Picturebox is included"
End If
End Sub
'-----------------------------------------------------------
Private Sub command1_Click()
MySub Image1
End Sub
'-----------------------------------------------------------
Can anyone explain it to me?
Your help is much appreciated.
-
You can only use ismissing with variants, you can pass pictureboxes in the variant but instead, i suggest that use
Code:
If pic Is nothing then
Instead