Hi John,
In order to trap an event raised by Class1 in Class2, you must declare a
WithEvents object reference to Class1 inside Class2, then create an event
stub procedure for the event being raised. A very simple (and admittedly
contrived) example would look like this:
-----------
In Class1
-----------
Event MyEvent()
Public Sub RaiseMyEvent()
RaiseEvent MyEvent
End Sub
-----------
In Class2
-----------
Private WithEvents mclsClass1 As Class1
Private Sub Class_Initialize()
Set mclsClass1 = New Class1
End Sub
Private Sub mclsClass1_MyEvent()
MsgBox "mclsClass1_MyEvent was caught in Class2"
End Sub
Public Sub RaiseMyEvent()
mclsClass1.RaiseMyEvent
End Sub
-----------
In Module1
-----------
Sub Demo()
Dim clsClass2 As Class2
Set clsClass2 = New Class2
clsClass2.RaiseMyEvent
End Sub
When you run this code you'll see a message box that is displayed by
Class2 when it catches the event raised by Class1.
--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/
* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *
"John Peterson" wrote in message
...
Is it possible to create an event in one class module and then raise that
event from another class module. I have a class module which provides
event
trapping for a control type - class1. The other class module creates a
collection of controls - class2. If I change a control's state through a
class1 click event, I would like to raise an event which will go to the
collection (class2) and update a Boolean array holding the state condition
on each control in the collection. I have tried several examples of
Event-RaiseEvent usage. None of these seem to work across class module
boundaries. I would appreciate any advice on this subject. Regards,
John