Showing a new form

How do you handle the click of the "x" in the top corner to close the application? How do you unload the application? I can do it with a button click but how do I do it with the "x"?
 
No, I havent but something must still be open. How do you close a form when a button is clicked? In VB6 I used Unload Me but in .NET you cant. What should i be doing?
 
If you have used Application.Run() with no arguments to start a message loop for your program, you will need to manually call Application.Exit() when all your forms are closed and you are ready to terminate.
 
if you want the whole application to close then use this...
Code:
    Private Sub Form1_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
        End
    End Sub
if you want to unload just the 1 form then id use the way of showing the form as divil showed above "Dim frm as form"
then id do something like...
Code:
    Private Sub Form1_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
        Set frm = nothing
    End Sub
 
Dim myForm as FrmTest = New FrmTest

myForm is the name of a variable (container) for your form, FrmTest is the name of the class of your Form, New FrmTest in to create a new instance of the class (form) inside the container, in this case myForm
 
Back
Top