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

Re: Ensuring a Form Object is set to Nothing by hirf-spam-me-here

hirf-spam-me-here
Thu Jun 03 10:42:18 CDT 2004

* "=?Utf-8?B?RHlsYW4=?=" <anonymous@discussions.microsoft.com> scripsit:
> 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.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>