WithEvent

J

John\\

I have an EXE file that calls a DLL.
I would like the DLL to RaiseEvent on the EXE, I have pasted sample code for
the DLL and EXE

My problem is that the Class doesn't seem to be able to Raise the Event on
my executable... Any ideas, or errors you see?
Thanks in advance,
J.

-------- START OF CLASS ----------------------
' The class project is called ClassTest
Public Class Class1

Public Event TestRaiseEvent()

Public Sub Test()

RaiseEvent TestRaiseEvent()

End Sub

End Clas

-------- END OF CLASS --------------


--------- EXE CODE ---------------
Public clsTest as New ClassTest.Class1
Public WithEvents TestDLL As ClassTest.Class1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

clsTest.Test()


End Sub

Public Sub Test_DLL_Test() Handles TestDLL.TestRaiseEvent

MsgBox("This is a test of the Raise Event Function....")

End Sub

--------- OF OF EXE ---------------
 
M

Marina Levit [MVP]

You are raising the event on object clsTest, but handling the event of
object TestDLL. You need to handle the event of the object actually raising
the event - which in this case is clsTest.

Btw, TestDLL doesn't look like it is ever getting instantiated - maybe you
are doing that elsewhere in a code segment you are not showing here?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top