On Form2 I have
Me.close()coded for an exit button.
When I click on the exit button on form 2, form 1(main) stays open.
What can I do to not have this happening??




Posted 28 January 2013 - 07:51 AM
Me.close()coded for an exit button.
Posted 28 January 2013 - 08:05 AM
Posted 28 January 2013 - 08:23 AM
Private Sub doThis()
Me.Close()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim frm2 As New Form2
AddHandler frm2.FormClosed, Sub() doThis()
frm2.Show()
End Sub
This post has been edited by andrewsw: 28 January 2013 - 08:24 AM
Posted 28 January 2013 - 08:34 AM
This post has been edited by AdamSpeight2008: 28 January 2013 - 08:46 AM
Posted 28 January 2013 - 09:29 AM
Private WithEvents frm2 As Form2
Private Sub Form2_Closed(sender As Object, e As Windows.Forms.FormClosedEventArgs) Handles frm2.FormClosed
Me.Close()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
frm2 = New Form2
frm2.Show()
This post has been edited by andrewsw: 28 January 2013 - 09:30 AM
Posted 28 January 2013 - 10:27 AM
andrewsw, on 28 January 2013 - 09:29 AM, said:
Private WithEvents frm2 As Form2
Private Sub Form2_Closed(sender As Object, e As Windows.Forms.FormClosedEventArgs) Handles frm2.FormClosed
Me.Close()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
frm2 = New Form2
frm2.Show()
Posted 28 January 2013 - 10:39 AM
Private Sub Form2_FormClosed(sender As Object, e As FormClosedEventArgs) Handles Me.FormClosed
Application.Exit()
' or....
For Each frm As Form In Application.OpenForms
frm.Close()
Next
End Sub
Posted 29 January 2013 - 07:25 AM
andrewsw, on 28 January 2013 - 10:39 AM, said:
Private Sub Form2_FormClosed(sender As Object, e As FormClosedEventArgs) Handles Me.FormClosed
Application.Exit()
' or....
For Each frm As Form In Application.OpenForms
frm.Close()
Next
End Sub
Posted 31 January 2013 - 09:28 AM
Application.exit()
Application.exit()
Posted 31 January 2013 - 09:35 AM
Me.Hide Form2.Show
