Closing and discarding a form 
Author Message
 Closing and discarding a form

I have two forms: MDIForm and ChildForm.

To open the child form from the MDI I do:

Dim f As frmChildForm
      If IsNothing(f) Then
            f = New frmChildForm()
            f.MdiParent = Me  
       End If
      f.Show()        

where f is a module variable.

But if I close the ChildForm whith Me.Close and then I try to open it
again, I get problem, because f si not Nothing.
From the other site, I cannot remove the IF...THEN that avoids two
instances of the same form.

Any suggestion?

Thank you.
Gio



Tue, 26 Apr 2005 19:35:50 GMT  
 Closing and discarding a form

Quote:
> I have two forms: MDIForm and ChildForm.

> To open the child form from the MDI I do:

> Dim f As frmChildForm
>       If IsNothing(f) Then
>             f = New frmChildForm()
>             f.MdiParent = Me  
>        End If
>       f.Show()        

> where f is a module variable.

> But if I close the ChildForm whith Me.Close and then I try to
> open it again, I get problem, because f si not Nothing.
> From the other site, I cannot remove the IF...THEN that avoids two
> instances of the same form.

> Any suggestion?

Dim WITHEVENTS f As frmChildForm
      If IsNothing(f) Then
            f = New frmChildForm()
            f.MdiParent = Me  
       End If
      f.Show()      

sub f_closed (...) handles f.closed
    f = nothing
end sub

Armin



Tue, 26 Apr 2005 20:09:55 GMT  
 Closing and discarding a form
On Fri, 8 Nov 2002 13:09:55 +0100, "Armin Zingler"

Quote:

>Dim WITHEVENTS f As frmChildForm
>      If IsNothing(f) Then
>            f = New frmChildForm()
>            f.MdiParent = Me  
>       End If
>      f.Show()      

>sub f_closed (...) handles f.closed
>    f = nothing
>end sub

But f is a local variable of the MdiParent form.
If I do f=nothing in the closed event of the child form (f) I get the
error message:
"'frmMethod' is a type and cannot be used as an expression."
:-(


Tue, 26 Apr 2005 22:21:43 GMT  
 Closing and discarding a form

Quote:
> On Fri, 8 Nov 2002 13:09:55 +0100, "Armin Zingler"

> >Dim WITHEVENTS f As frmChildForm
> >      If IsNothing(f) Then
> >            f = New frmChildForm()
> >            f.MdiParent = Me  
> >       End If
> >      f.Show()      

> >sub f_closed (...) handles f.closed
> >    f = nothing
> >end sub

> But f is a local variable of the MdiParent form.
> If I do f=nothing in the closed event of the child form (f) I
> get the error message:
> "'frmMethod' is a type and cannot be used as an expression."
> :-(

The code is in the MDIparent.

Armin



Tue, 26 Apr 2005 23:21:34 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Forms, primary thread closing when closing startup form

2. Form Close Button Does Not Close the Form

3. Open form, close form, open form = disposed object exception

4. Prevent user from closing form using caption close button

5. Closing a form and closing Word

6. Tip : VB.NET Form Won't Close on Me.Close + User Controls

7. Form does not close from the UpperRight X Close button

8. Do I Find or Write the new Form Events (Activated,DeActivated,Closing,Closed)

9. problems using close [x] button when closing forms.

10. window.close closes webbrowser but not the form itself

11. How to prevent user closing a mdi form using the close control button

12. window.close closes Webbrowser but not the form itself

 

 
Powered by phpBB® Forum Software