Ensuring a Form Object is set to Nothing

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Say I create a form as a child in the following fashion

dim Mainfrm as frmMachine ' Globa

public sub CreateForm(
Mainfrm = New frmMachin
Mainfrm.MdiParent = M
Mainfrm.Show(
end su

Now when I close the form (clicking the x), the form gets closed but Mainfrm is still referencing the form address

How do I ensure that Mainfrm gets set to Null, so that I can test for the forms existence? Is Mainfrm a type of hanging pointer

What happens when, after the form has been closed and CreateForm() is called again? Does the original object get freed or overwritten? Will I have a memory leak? Is the memory freed as I read that memory is only freed when no objects are referencing that memory

Am I approaching this incorrectly

thanks in advanc

Dyla
 
* "=?Utf-8?B?RHlsYW4=?= said:
Say I create a form as a child in the following fashion:

dim Mainfrm as frmMachine ' Global

public sub CreateForm()
Mainfrm = New frmMachine
Mainfrm.MdiParent = Me
Mainfrm.Show()
end sub

Now when I close the form (clicking the x), the form gets closed but
Mainfrm is still referencing the form address.

Add a handler to the form's 'Closed' event using 'AddHandler' and set
the variable to 'Nothing' there.
 
Back
Top