Private Sub Form_Unload(Cancel As Integer)
Set aa = Nothing
Set bb = Nothing
End Sub
===================
The object I wrote "BossCheckerOject.QueryCmd" would fire a DataArrival event. I used the "aa" object to send a query out. I expected that I should received an event from the "aa" object. But then the event handler of "bb" handle the event.
I am not so sure if there is any bug in my original ActiveX DLL.
If you don't mind, could you give me some comments on my test program. I made a group project, which contains a dummy ActiveX DLL and a container program.
I created 3 objects in the container programs, and implements 3 event handlers in this container program. I only called the first object function once. But then all three event handlers got the events.... is there anything that I made it wrong?
All instances of your class are using the same Form and thus the same timer. When the Timer_Timer event fires, all three class instances get the event and in turn all three raise their Data_Arrival events.
Create a new instance of the Form for each class - or add a new Timer to the form when the class gets initialized.
VB Code:
Private Sub Class_Initialize()
Dim objForm As Form
Set objForm = New Form1
Load objForm
Set myTimer = objForm.Timer1
End Sub
Private Sub Class_Terminate()
Set myTimer = Nothing
End Sub
Also instead of using Form1.Timer.Enabled = False use myTimer.Enabled = False
hi brucevde, I gotta say thank you again.
It fixed my problem now. Thank you so much.
What I was thinking is that the Active DLL is using the Apartment threading model, and so I expected that every instance of class is residing in its own apartment... but seems like the form is not in the apartment (which I thought it was)... Hehehe..
I really appreaciated that you pin-point my error.
for the sample program that I attached above, there is only thread (the container program), which has ONE apartment and all three objects or instances that I created are all resided in this apartment. Am I right?
And there will be another apartment only when there is another client progam (thread) that uses the same dll?