I am trying to declare a variable in a VB6 module as follows:
Public WithEvents MyObject As MyClass
The help files say that WithEvent
Write a class that accepts your global object as a parameter and sinks its events.
' Class MySink
Private WithEvents m_oSink As MyClass
Friend Sub frInit(oSink As MyClass)
Set m_oSink = oSink
End Sub
Private Sub m_oSink_MyEvent()
'--- implement event
End Sub
Create an instance of this class in your .bas module.
Public g_oMyObject AS MyClass
Private m_oMySink As MySink
Sub Main()
Set g_oMyObject = New MyClass
Set m_oMySink = New MySink
m_oMySink.frInit g_oMyObject
End Sub