View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
RyanH RyanH is offline
external usenet poster
 
Posts: 586
Default Do I need to destroy a collection I made when I am done with it?

I have some code that intializes a new collection, runs code using the
collection and then ends. Do I need to destroy the collection so it doesn't
take up memory or does this automatically happen when the procedure is over?
Is there a way to see what is in memory?
Option Explicit

Private Sub cboMounting_Change()

Dim colPoleSpecsAll As Collection
Dim colPoleSpecsData As Collection
Dim ctrl As Control

Set colPoleSpecsAll = New Collection
With colPoleSpecsAll
.Add lblPoles
.Add cboPoles
.Add lblShape
.Add cboShape
.Add lblFieldPoleSize
.Add cboFieldPoleSize
End With

Set colPoleSpecsData = New Collection
With colPoleSpecsData
.Add cboPoles
.Add cboShape
.Add cboFieldPoleSize
End With


If cboMounting.ListIndex 1 Then
For Each ctrl In colPoleSpecsAll
ctrl.Enabled = True
Next ctrl
For Each ctrl In colPoleSpecsData
ctrl.BackColor = vbWindowBackground
Next ctrl
Else
For Each ctrl In colPoleSpecsAll
ctrl.Enabled = False
Next ctrl
For Each ctrl In colPoleSpecsData
ctrl.BackColor = vbButtonFace
Next ctrl
End If

End Sub

--
Cheers,
Ryan