Consider the following code in a VBA module called Module1
:
Sub StartTest()
Dim frm As UserForm1
Set frm = New UserForm1
frm.Show
End Sub
Sub Notify(fromForm As UserForm1)
MsgBox "Notified."
End Sub
And the following code in UserForm1
:
Private Sub CommandButton1_Click()
Module1.Notify (Me)
End Sub
When I run StartTest
the form appears, and when I click the button, I'm getting a "Type mismatch" error on Module1.Notify (Me)
in the CommandButton1_Click()
sub. Why?
If I change Module1.Notify (Me)
to Call Module1.Notify(Me)
(thanks @sous2817 for pointing this out) or to Module1.Notify Me
, then I don't get the error. So why does it happen when I use Module1.Notify (Me)
?