"Closing" a Form

G

Guest

I am working with a button-driven main menu form that I want to disappear
upon clicking one of its buttons, and then reappear upon closing the sleected
form; i.e., the main menu needs to "unload" while working with the customer
update screen, then when the user exits the customer update screen, the main
menu is redisplayed. The code I am using from the main menu is:

Dim objForm As New frmAbout
objForm.ShowDialog()
objForm.Dispose()

I've tried Me.Close but had the application end. I've tried Me.Hide, but
couldn't get the main menu to reappear! Thanks in advance for being nice to
me!
 
G

Guest

Try this

///
'In your menu form code
Dim objForm As New frmAbout
Me.Hide
objForm.ShowDialog()
Me.Show
objForm.Dispose()
\\\
 
J

Jack Russell

Sarika said:
Try this

///
'In your menu form code
Dim objForm As New frmAbout
Me.Hide
objForm.ShowDialog()
Me.Show
objForm.Dispose()
\\\
Is the dispose needed? I have never seen it in any MS examples.
 
G

Guest

It is not necessary.

However if you want to release resources associated with the object that is
being described then you can write a dispose method and do the clean up work
there.

HTH
 
C

Chris Dunaway

If you show the form with ShowDialog, then you should call .Dispose as
it is not called automatically. If you show the form with .Show, then
it is automatically disposed when it is closed.
 
G

Guest

Chris,

Won't the closing of the form (displayed using ShowDialog) eliminate the
need for an explicit Dispose? (unless one has coded a Dispose method to
handle graceful exit)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top