Picturebox (x3)
Label (x4)
TextBox (x2)
ListBox
ScrollBar
CommonDialog
ImageList
Timer
In code, the control has the following member Objects:
m_AllVersions As Collection
m_ModulePaths As Collection
m_Parameters As Collection
m_Measurements As Collection
In my UserControl_Initialize routine, I have a bunch of lines that set flags, configure the various texboxes and things, and I set each Collection to a New one. Nothing very fancy. I put a Debug.Print statement in to let me know that the Object has been created.
verbatem, here is my terminate method:
Expand|Select|Wrap|Line Numbers
- Private Sub UserControl_Terminate()
- 'remove references to objects
- Set m_AllVersions = Nothing
- Set m_ModulePaths = Nothing
- Set m_Parameters = Nothing
- Set m_Measurements = Nothing
- Debug.Print vbTab & "OPERATION DESTROYED!!"
- End Sub
Expand|Select|Wrap|Line Numbers
- Friend Function CreateOperation() As Operation
- Dim Opn As Operation
- Static ControlIndex As Integer
- Set Opn = Controls.Add("Project1.Operation", "Module" & m_ControlIndex _
- & "Operation" & ControlIndex)
- Opn.Move 0, 0, Extender.Width, Extender.Height
- Opn.ControlIndex = ControlIndex
- ControlIndex = ControlIndex + 1
- Set CreateOperation = Opn
- End Function
- Friend Sub DestroyOperation(ByRef Opn As Operation)
- Dim Index As Integer
- 'explicitly remove reference to Operation in
- ' all Parameter objects
- For Index = 0 To Opn.ParamCount - 1
- Opn.RemoveParameter 0
- Next
- 'explicitly remove reference to Operation in
- ' all Measurement Objects
- For Index = 0 To Opn.MeasCount - 1
- Opn.RemoveMeasurement 0
- Next
- 'Remove Operation object from Controls Collection
- Controls.Remove "Module" & m_ControlIndex & "Operation" & Opn.ControlIndex
- Set Opn = Nothing
- End Sub
Okay, so to test that everything is working, I just create and destroy the Operation Objects in a loop:
Expand|Select|Wrap|Line Numbers
- Dim i As Integer
- Dim Opn As Operation
- For i = 1 To 1000
- Debug.Print "CREATING OPERATION " & i
- Set Opn = Modl.CreateOperation
- Modl.DestroyOperation Opn
- Set Opn = Nothing
- Next
Any ideas? Is there something unique about ActiveX objects that prevents them from being returned to memory properly?