Hi all,
We need to develop a COM component in VB.Net for use in COM client applications. We developed a sample COM Interop component in VB.Net and tried to use it in VB. The sample component has a Message property, a DisplayText method and an OnMessageDisplay event. Things work smoothly for the property assignment and method invocation. However when it comes to handling the OnMessageDisplay event, I can't seem to find how I can handle it.
Here's the code in VB6:
For a true COM component I could simply have used WithEvents myObj and the job would be done. However here I am stuck as to how I can specify the OnMessageDisplay() procedure as the event handler for the OnMessageDisplay event. Can someone help me out with this?Code:Option Explicit Dim myObj As TestInterop.TestInterop Dim myEvent As OnMessageDisplayEventHandler Private Sub Form_Click() myObj.Message = "Hello Anand" myObj.DisplayText End Sub Private Sub Form_Load() Set myObj = New TestInterop.TestInterop myevent. myObj.add_OnMessageDisplay myEvent End Sub Private Sub OnMessageDisplay() MsgBox ("Event handler invoked") End Sub
.





Reply With Quote