DavidLogue
Programmer
Hi,
I have defined two events in a collection as follows...
Public Event NewObject(mcount As Integer)
Public Event KillObject(mcount As Integer)
Private mCol As Collection
These are raised in the class (collection) at
1) Public Function Add(...
...
If Len(sKey) = 0 Then
mCol.Add objNewMember
Else
mCol.Add objNewMember, sKey
End If
'return the object created
Set Add = objNewMember
Set objNewMember = Nothing
RaiseEvent NewObject(COUNT)
2) Private Sub Class_Terminate()
'destroys collection when this class is terminated
Set mCol = Nothing
RaiseEvent KillObject(0)
End Sub
Then in a form I Raise the 'NewObject' event when I add a new member to the collection. This works fine.
Private Sub colCollection_NewObject(mcount As Integer)
StatusBar1.Panels(1).Text = mcount
End Sub
My problem is that I can't raise the 'Kill Object' Event when I set the instance of the collection to Nothing.
Private Sub colCollection_KillObject(mcount As Integer)
StatusBar1.Panels(1).Text = ""
End Sub
Do you have any ideas how I could raise an event when I destroy a collection?
I have defined two events in a collection as follows...
Public Event NewObject(mcount As Integer)
Public Event KillObject(mcount As Integer)
Private mCol As Collection
These are raised in the class (collection) at
1) Public Function Add(...
...
If Len(sKey) = 0 Then
mCol.Add objNewMember
Else
mCol.Add objNewMember, sKey
End If
'return the object created
Set Add = objNewMember
Set objNewMember = Nothing
RaiseEvent NewObject(COUNT)
2) Private Sub Class_Terminate()
'destroys collection when this class is terminated
Set mCol = Nothing
RaiseEvent KillObject(0)
End Sub
Then in a form I Raise the 'NewObject' event when I add a new member to the collection. This works fine.
Private Sub colCollection_NewObject(mcount As Integer)
StatusBar1.Panels(1).Text = mcount
End Sub
My problem is that I can't raise the 'Kill Object' Event when I set the instance of the collection to Nothing.
Private Sub colCollection_KillObject(mcount As Integer)
StatusBar1.Panels(1).Text = ""
End Sub
Do you have any ideas how I could raise an event when I destroy a collection?