"Closing" a Form

  • Thread starter Thread starter Guest
  • Start date Start date
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!
 
Try this

///
'In your menu form code
Dim objForm As New frmAbout
Me.Hide
objForm.ShowDialog()
Me.Show
objForm.Dispose()
\\\
 
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.
 
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
 
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.
 
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)
 
Back
Top