Hi All,

I required callbacks from my activeX exe, for that i raised an event from Exe Class. But the problem i m facing is when i'm trying to stop one instance both will be stopped.

How do i get callbacks from my exe having multiple instances to client application?

The Code for sample application is:

For Client application:
======================================================
Type : StandardEXE
Forms : Added one Form - Name:frmCount
References : Reference to my ActiveX exe : Named: ActiveCount
Controls :
Two Labels : lblCountFirst, lblCountSecond - to show the count from events
Four Command buttons: cmdStartFirst, cmdStopFirst
cmdStartSecond, cmdStopSecond
======================================================
Code For Client:

Option Explicit
Dim WithEvents exe1 As Class1
Dim exeConnect1 As Class2
Dim WithEvents exe2 As Class1
Dim exeConnect2 As Class2

Private Sub cmdStartFirst_Click()
Set exeConnect1 = New Class2
Set exe1 = exeConnect1.ClassMonitor
exeConnect1.LoopStart = False
exe1.DisplayCounter
End Sub
Private Sub cmdStartSecond_Click()
Set exeConnect2 = New Class2
Set exe2 = exeConnect2.ClassMonitor
exeConnect2.LoopStart = False
exe2.DisplayCounter
End Sub
Private Sub cmdStopFirst_Click()
exeConnect1.LoopStart = True
End Sub
Private Sub cmdStopSecond_Click()
exeConnect2.LoopStart = True
End Sub

Private Sub exe1_NumberChanged(newNumber As Long)
lblCountFirst = newNumber
DoEvents
End Sub
Private Sub exe2_NumberChanged(newNumber As Long)
lblCountSecond = newNumber
DoEvents
End Sub
======================================================
Type : ActiveX EXE
Two Classes: Class1 - Instancing Property: 2-PublicNotCreatable
and Class2 - Instancing: 5-MultiUse
One Module: Module1
======================================================
Code for Module1 :

Public gClassMonitor As Class1
Public ExitLoop As Boolean
======================================================
Code for Class2 :

Option Explicit
Private Sub Class_Initialize()
If gClassMonitor Is Nothing Then
Set gClassMonitor = New Class1
End If
End Sub
Public Property Get ClassMonitor() As Class1
Set ClassMonitor = gClassMonitor
End Property
Public Property Get LoopStart() As Boolean
LoopStart = ExitLoop
End Property
Public Property Let LoopStart(ByVal bNewValue As Boolean)
ExitLoop = bNewValue
End Property
Private Sub Class_Terminate()
Set gClassMonitor = Nothing
End Sub
======================================================
Code for Class1:

Option Explicit
Public Event NumberChanged(newNumber As Long)
Public Function DisplayCounter() As Long
Dim cnt As Long
Do
cnt = cnt + 1
If cnt >= 100000 Then cnt = 0
RaiseEvent NumberChanged(cnt)
If ExitLoop = True Then Exit Do
DoEvents
Loop
End Function
======================================================
I require both instances from my client application to work separately,
as right now whenever i am trying to stop one loop from first instance
both instances stopped their working.

Please help me out to solve this situation, as i m getting confused what is happening herewith?????


Thanks,,,,