M
Miguel Ribeiro
Hi,
The crux of my problem is that I want to destroy an object without using
the reference (by using a collection etc.) and have the reference
basically show 'nothing'
I have a MDI form with forms that are going to be displayed on it. The
layout is quite complex since I am going to try get the same
functionality as Outlook. What I need to know is this:
I have a module with variables containing all the forms e.g.
Public frmSetup as SetupForm
Public frmManagement as ManagementForm ETC...
I have made them public as since this application will function like
outlook with 3 windows (forms) side by side, each form has to
communicate with the next form.
I load (for example) the frmSetup in the Left Panel on the MDI form, I
then want to, at a later stage, load frmManagement into the left panel
on the MDI form and clear all the previous forms that were loaded into
the panel without using their variable name (frmSetup, frmManagement
etc.) I do this by running this bit of code:
Dim frmControl As Control
For Each frmControl In pnlPanel.Controls
If TypeOf frmControl Is Form Then
If frmControl.Name <> objForm.Name Then ' If
this is not the form I want to load in
the panel, then destroy it
CType(frmControl, Form).Close()
CType(frmControl, Form).Dispose()
frmControl = Nothing ' It doesn't seem to work
Application.DoEvents()
End If
End If
Next
It is at this point that I am stuck, when I set all the other forms to
nothing (via the collection) the variable that references the form is
not set to nothing. I thought if I deleted the underlying object (by
setting it to nothing? and Dispose etc) that it would clear all the
references to that object in memory.
Can anyone help
Thanks
Miguel Ribeiro
The crux of my problem is that I want to destroy an object without using
the reference (by using a collection etc.) and have the reference
basically show 'nothing'
I have a MDI form with forms that are going to be displayed on it. The
layout is quite complex since I am going to try get the same
functionality as Outlook. What I need to know is this:
I have a module with variables containing all the forms e.g.
Public frmSetup as SetupForm
Public frmManagement as ManagementForm ETC...
I have made them public as since this application will function like
outlook with 3 windows (forms) side by side, each form has to
communicate with the next form.
I load (for example) the frmSetup in the Left Panel on the MDI form, I
then want to, at a later stage, load frmManagement into the left panel
on the MDI form and clear all the previous forms that were loaded into
the panel without using their variable name (frmSetup, frmManagement
etc.) I do this by running this bit of code:
Dim frmControl As Control
For Each frmControl In pnlPanel.Controls
If TypeOf frmControl Is Form Then
If frmControl.Name <> objForm.Name Then ' If
this is not the form I want to load in
the panel, then destroy it
CType(frmControl, Form).Close()
CType(frmControl, Form).Dispose()
frmControl = Nothing ' It doesn't seem to work
Application.DoEvents()
End If
End If
Next
It is at this point that I am stuck, when I set all the other forms to
nothing (via the collection) the variable that references the form is
not set to nothing. I thought if I deleted the underlying object (by
setting it to nothing? and Dispose etc) that it would clear all the
references to that object in memory.
Can anyone help
Thanks
Miguel Ribeiro