forms problem

tennisfreak

Member
Joined
Sep 7, 2007
Messages
13
Location
El Salvador
Programming Experience
Beginner
In vs2003, I have two forms... on one I have an intro form with a button that shows the second form, when I push this button I want form1 to close and form2 to show...

the point is... when I use this code in the button (on click event):

dim frm2 as new form2
frm2.show
me.close()

' it closes everything, I want only form1 to close. :confused:
 
This may be your project properties. I cannot speak for VS2003, but in VS2005, there is an option in your project's properties that say "shutdown mode" where you can tell your app to shutdown only when all forms are closed. That way, you will be able to close frm1 and close the application only when frm2 closes.

However, if the behavior you are looking for is that when frm2 closes, frm1 shows again, you might consider catching the FormClosing event, set args.Cancel = true and just hide frm1. Then, when Frm2 closes again, catch its FormClosing event (don't cancel it) and show frm1.
 
in VS2003, I used to have the program start from sub main where I ran form1 as an application followed by form2
VB.NET:
Public Sub Main()
  Dim frm1 as new Form1
  Application.Run(frm1)
  Dim frm2 as new Form2
  Application.Run(frm2)
End Sub
 
Back
Top