Question vb6 handle .net com class events

blachogi

New member
Joined
Nov 13, 2009
Messages
2
Programming Experience
Beginner
i have the ComClassSearchCustomers class and interface IComClassSearchCustomersat .net which used to create a tlb file. The class raise an event inside new. After that i have a vb6 form Form1 which catch the event , but it never see the event. Any ideas?
Option Strict On
Option Explicit On
Imports System.Runtime.InteropServices

<Guid("BB86EB1C-6444-424f-B83B-A667561E06C3"), _
ComSourceInterfaces(GetType(IComClassSearchCustomers))> _
Public Class ComClassSearchCustomers

Public Delegate Sub printReportEventHandler(ByVal codes As String)
Public Event printReport As printReportEventHandler

Public Sub New()
MyBase.New()
RaiseEvent printReport
End Sub
End Class


Imports System.Runtime.InteropServices

<Guid("D8F7EC74-0EFC-4e43-9B59-4CF741DF616D"), _
InterfaceType(ComInterfaceType.InterfaceIsIDispatch)> _
Public Interface IComClassSearchCustomers
<DispId(1)> _
Sub printReport(ByVal codes As String)
End Interface
Public WithEvents Instance As Search.ComClassSearchCustomers

Private Sub Form_Load()
Set Instance = New Search.ComClassSearchCustomers
End Sub

Private Sub Instance_printReport(ByVal codes As String)
MsgBox ("raise")
End Sub
 
thanks for the reply. I create my com class like the site instructions , but i do not see any results. can you publish a sample for your code?
 
If you mean sample for raising event from constructor I just told you it won't work.
 

Latest posts

Back
Top