Closing startup form without closing program

Adrammelech

Member
Joined
Mar 9, 2007
Messages
11
Programming Experience
Beginner
I'm workin on a game now that starts out with a form that basically you click to enter. What im having a problem is closing that form when I go to the next form but using Me.Close() exits off of the program and Me.Hide() dont exit when I close the second form. Any advice?

Sorry for puting it in general instead of forms, wasn't thinkin.
 
Go to Project Properties, Application tab. There you have Shutdown mode, by default it's set to "When startup form closes", change this to "When last form closes".
 
If Form1 is the window with like the New Game or Credits or Options Butotns on it. You could do Me.hide in Form2_load, then on form2_FormClosing do form1.show or application.exit

Like this: This is the code for form1
VB.NET:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Hide()
form2.show()
End Sub
End Class

Then: The Code for Form2
VB.NET:
Public Class Form2
Private Sub Form2_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
Form1.Show()
End Sub
End Class


I think this is kind of what you wanted. If not sorry, for confusing you if I did.
 
The way I got round this is to make sure that you load the next Form/screen etc before you close the First window... i would show you in code but I'm not entirely sure how it works yet....

i.e.
VB.NET:
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] BtnEnd_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] 'System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] BtnEnd.Click[/SIZE]
 
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] SectionSelect [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] SectionSelect[/SIZE]
[SIZE=2]Form2.Show()[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].Close()[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]

This worked for me!

Hope this helps!

Matt

(Ah ha! Sussed the code thingy!)
 
Last edited:
Back
Top