Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RaiseEvents not passing variables from Class Module

Status
Not open for further replies.

caerdydd

Programmer
Mar 2, 2004
35
GB
Hello

I am trying to use the RaiseEvents in Excel VBA to send variables from one class module to another.

Below is what I have so far.

cls1:
Event itsdone(Company As Variant, Number As String)

Run code here

'This next line gives me the variables from the procedure
Enditall mycompany, mynumber

Private Sub Enditall(Company As Variant, Number As String)
RaiseEvent itsdone(Company, Number)


cls2:
Private WithEvents oCompany As cls1

Private Sub Class_Initialize()
If oCompany Is Nothing Then Set oCompany= New cls1
Exit Sub

'This next line should then get the data from the RaiseEvent
Private Sub oCompany_itsdone(Company As Variant, Number As String)

========================

The problem is that the code runs but when gets to the RaiseEvent nothing happens it just moves on to the next line of code which is End Sub. I am expecting it to pass the variables from cls1 to the oComapny_itsdone sub in cls2.

I'd be very grateful if anyone knows a way around this and if more information is needed i can pass it on.
Thanks in advance.
 
When your code runs in an instance of cls2 - do you pass code execution to oCompany (cls1) and it goes through RaiseEvent?
Could you post more complete code that would allow to trace it?
You could try my faq: faq707-4973, faq707-4974, faq707-4975, faq707-4976.

combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top