My first post here.
I have c# .dll, to use with a scanner. I intend to use it with some legacy vb6 applications.
The .dll raises an event with the scanned code using RaiseArgs.
I am trying to write an .ocx library for use with VB6 apps.
To catch this event in an .ocx library I am trying to adapt this code:
Sub TestEvents()
Dim Obj As New Class1
' Associate an event handler with an event.
AddHandler Obj.Ev_Event, AddressOf EventHandler
' Call the method to raise the event.
Obj.CauseSomeEvent()
' Stop handling events.
RemoveHandler Obj.Ev_Event, AddressOf EventHandler
' This event will not be handled.
Obj.CauseSomeEvent()
End Sub
Sub EventHandler()
' Handle the event.
MsgBox("EventHandler caught event.")
End Sub
Public Class Class1
' Declare an event.
Public Event Ev_Event()
Sub CauseSomeEvent()
' Raise an event.
RaiseEvent Ev_Event()
End Sub
End Class
But I am getting
Invalid use of AddressOf operator error when I call: AddHandler Obj.Ev_Event, AddressOf EventHandler
What could be probable cause of this error?
I suspect, that i am not going in the right direction with solving this task, so would it be a better way to approach this problem?
Private Sub ObjectName_EventName()
. Otherwise see stackoverflow.com/q/39511528/11683. – GSerg