title: Invalid use of AddressOf operator VB6
body: <p>My first post here.</p>
  
  <p>I have c# .dll, to use with a scanner.
  I intend to use it with some legacy vb6 applications.</p>
  
  <p>The .dll raises an event with the scanned code using RaiseArgs.</p>
  
  <p>I am trying to write an .ocx library for use with VB6 apps.</p>
  
  <p>To catch  this event in an .ocx library I am trying to adapt this code:</p>
  
  <pre><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
  </code></pre>
  
  <p>But I am getting 
  Invalid use of AddressOf operator error when I call: <code>AddHandler Obj.Ev_Event, AddressOf EventHandler</code></p>
  
  <p>What could be probable cause of this error?</p>
  
  <p>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?</p>