I have VB6 code that creates an instance of a class that handles events that arise from a VB.NET component. VB6 is pretty simple:
private m_eventHandler as new Collection
...
public sub InitSomething()
dim handler as EventHandler
set handler = new EventHandler
m_eventHandler.Add handler
...
m_engine.Start
end sub
Note that the event handler object must go beyond the init method (therefore, it is stored in the collection). Also note that m_engine.Startindicates the point in the program where the VB.NET component will start raising events.
Actual event handler (on request):
Private WithEvents m_SomeClass As SomeClass
Private m_object as Object
...
Private Sub m_SomeClass_SomeEvent(obj As Variant)
Set obj = m_object
End Sub
Note what is m_objectinitialized when the instance is created EventHandler.
The VB.NET code that raises the event is even simpler:
Public ReadOnly Property SomeProp() As Object
Get
Dim obj As Object
obj = Nothing
RaiseEvent SomeEvent(obj)
SomeProp = obj
End Get
End Property
, debug VB6, InitSomething ( VB6 ). InitSomething .
, , . , , .
, VB.NET VB6 Visual Studio ( ).