title: VB6 Implements & events
body: <p>I have an older VB6 project that I'm trying to add unit tests for.  I was breaking dependencies in classes by mocking objects.  Everything was going great until I found some dependencies that were raising events and now I've hit a wall.</p>
  
  <p>Here's a quick example of what I'm trying to do that DOESN'T WORK:</p>
  
  <p>ITab.cls:</p>
  
  <pre><code>Option Explicit
  
  Public Event Click(tabNumber As Integer)
  
  Public Sub SomeOtherFunction()
  
  End Sub
  </code></pre>
  
  <p>clsRealTab.cls:</p>
  
  <pre><code>Option Explicit
  Implements ITab
  
  Public Event Click(tabNumber As Integer)
  
  Public Sub ITab_SomeOtherFunction()
      'code here'
  End Sub
  </code></pre>
  
  <p>frmMain.frm:</p>
  
  <pre><code>Option Explicit
  
  Private WithEvents mTab as ITab
  
  Public Sub Main()
      Set mTab = New clsRealTab 'gives "Object or class does not support the set of events" error'
  End Sub
  </code></pre>
  
  <p>Does anybody know if there's a way to make this work or another way to go about handling this situation?</p>
  
  <p>I implemented a callback interface that I called <code>ITabEventsHandler</code>.  It looks like this:</p>
  
  <pre><code>Option Explicit
  
  Public Sub Click(intPreviousTab As Integer, objSSTab As Object)
  
  End Sub
  </code></pre>
  
  <p>Then I added <code>Implements ITabEventsHandler</code> to my form and pass the form as an <code>ITabEventsHandler</code> parameter to my clsTab initializer.  Instead of raising a custom <code>Click(...)</code> event, I can just call <code>mTabEventsHandler.Click(...)</code>.</p>
  
  <p>Thanks for the suggestion!</p>