Option Explicit
Public Event Click()
Private Sub Command1_Click()
RaiseEvent Click
End Sub
类模块中的代码:
Option Explicit
Public Event showTxt()
Dim WithEvents thePreForm As PreForm
Private Sub thePreForm_Click()
RaiseEvent showTxt
End Sub
Public Sub Start()
If thePreForm Is Nothing Then
Set thePreForm = New PreForm
End If
thePreForm.Show vbModal'此处如果用无模式窗体就不会出现问题。
End Sub
然后添加测试工程,在窗体上加一个按扭,并引用这个DLL工程。
Option Explicit
Dim WithEvents testEvent As MainClass
Private Sub Command1_Click()
Set testEvent = New MainClass
testEvent.Start
End Sub
Private Sub testEvent_showTxt()
MsgBox "afsfasd"
End Sub