I'm trying to write a subroutine to delete all objects in a collection and then end the macro. I thought the following would work, but it's not:
Sub mydelete(col As Collection)
Dim myobj As Object
For Each myobj In col
Set myobj = Nothing
Next
Set col = Nothing
End
End Sub
'with a test sub being:
Sub tester()
Dim x As MyClass
Set x = New MyClass
Dim mycol As New Collection
mycol.Add x
mydelete mycol
End Sub
'myclass has these method declarations:
Private Sub Class_Initialize()
MsgBox "Constructor called"
End Sub
Private Sub Class_Terminate()
MsgBox "Destructor called"
End Sub
Any suggestions? Is this possible?
-Venkman
Sub mydelete(col As Collection)
Dim myobj As Object
For Each myobj In col
Set myobj = Nothing
Next
Set col = Nothing
End
End Sub
'with a test sub being:
Sub tester()
Dim x As MyClass
Set x = New MyClass
Dim mycol As New Collection
mycol.Add x
mydelete mycol
End Sub
'myclass has these method declarations:
Private Sub Class_Initialize()
MsgBox "Constructor called"
End Sub
Private Sub Class_Terminate()
MsgBox "Destructor called"
End Sub
Any suggestions? Is this possible?
-Venkman