title: Consume/Subscribe custom events of class module
body: <p>I want to consume an event of a class module that I have written.
  The class module looks like this</p>
  
  <pre><code>''CError64Row
  Public Event ErrorClicked(ByVal row As Integer, ByVal column As Integer)
  
  Public WithEvents lblDescription As MSForms.Label
  Public WithEvents lblFile As MSForms.Label
  Public WithEvents lblRow As MSForms.Label
  Public WithEvents lblCol As MSForms.Label
  
  Public row As Long
  Public col As Long
  
  Private Sub lblDescription_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
     RaiseEvent ErrorClicked(row, col)
  End Sub
  
  Private Sub lblFile_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
     RaiseEvent ErrorClicked(row, col)
  End Sub
  
  Private Sub lblRow_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
     RaiseEvent ErrorClicked(row, col)
  End Sub
  
  Private Sub lblCol_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
     RaiseEvent ErrorClicked(row, col)
  End Sub
  </code></pre>
  
  <p>In one of my forms I create the <code>CError64Row</code> objects</p>
  
  <pre><code>Private m_Elements As Long
  
  Private mErrors() As CError64Row
  
  Private Sub UserForm_Initialize()
      m_Elements = 0
  End Sub
  
  Public Function SetError(text As String, filename As String, row As Integer, column As Integer) As String
      Dim ctl As control
  
     ReDim Preserve mErrors(m_Elements + 1)
  
      Dim errorRow As CError64Row
      Set errorRow = New CError64Row
      Set mErrors(m_Elements) = errorRow
  
      mErrors(m_Elements).row = row
      mErrors(m_Elements).col = column
      Set mErrors(m_Elements).lblDescription = Me.Controls.Add("forms.label.1")
      With mErrors(m_Elements).lblDescription
          .Left = 35
          .height = 14
          .Top = 18 + (m_Elements) * 14
          .width = 631
          .Caption = text
      End With
  
      Set mErrors(m_Elements).lblFile = Me.Controls.Add("forms.label.1")
      With mErrors(m_Elements).lblFile
          .Left = 665
          .height = 14
          .Top = 18 + (m_Elements) * 14
          .width = 106
          .Caption = filename
      End With
  
      Set mErrors(m_Elements).lblRow = Me.Controls.Add("forms.label.1")
      With mErrors(m_Elements).lblRow
          .Left = 770
          .height = 14
          .Top = 18 + (m_Elements) * 14
          .width = 36
          .Caption = CStr(row)
      End With
  
      Set mErrors(m_Elements).lblCol = Me.Controls.Add("forms.label.1")
      With mErrors(m_Elements).lblCol
          .Left = 805
          .height = 14
          .Top = 18 + (m_Elements) * 14
          .width = 36
          .Caption = CStr(column)
      End With
      m_Elements = m_Elements + 1
  End Function
  
  Public Sub CError64Row_ErrorClicked(ByVal row As Integer, ByVal column As Integer)
      MsgBox "MSG received"
  End Sub
  </code></pre>
  
  <p>I want to receive the ErrorClicked event but I am not sure how to subscribe to the event.
  I read in this answer <a href="https://stackoverflow.com/questions/49660399/is-it-possible-to-create-and-handle-a-custom-event-in-a-customized-userform">Is it possible to create and handle a custom Event in a Customized UserForm?</a> that I can "subscribe" via </p>
  
  <blockquote>
    <p>Private Sub [Provider]_MemberName</p>
  </blockquote>
  
  <p>but I doubt that this works with an object which is created in a method.
  How can I subscribe to an event of an object which was created in a method?</p>