-
Jun 30th, 2010, 12:16 PM
#1
Thread Starter
Junior Member
Close one form and open another
When I open my application I have the first form which opens as the Register form. When I press the Activate Button I want the MAIN form to open and I am using the code below as the last two line:
Main.ShowDialog()
Me.Close()
When the main form opens the Register form does not close and stays background.
If I close:
me.close()
main.showdialog()
then the whole application closes.
Any help on this matter?
-
Jun 30th, 2010, 12:31 PM
#2
Re: Close one form and open another
Since Main.ShowDialog() would cause VB6 to yak all over itself, I suspect you are using VB.NET.
Moved
-
Jun 30th, 2010, 01:36 PM
#3
Thread Starter
Junior Member
Re: Close one form and open another
Yes this is Vb.Net. Am I in the wrong place?
-
Jun 30th, 2010, 02:06 PM
#4
Re: Close one form and open another
Hi Mohdali, you are in the right place now! There are two things you need to change.
First, you must use Main.Show instead of Main.ShowDialog. Otherwise, your first form can't close until after Main closes.
Second, you need to go to the project properties, and change the Shutdown mode (near the bottom of the Application tab) from "when startup form closes" to "when last form closes".
BB
-
Jun 30th, 2010, 02:10 PM
#5
Re: Close one form and open another
[sorry, accidentally posted twice]
BB
-
Jun 30th, 2010, 10:06 PM
#6
Re: Close one form and open another
Also, you MUST Show the new form BEFORE you Close the current form. If you Close the current form first then the last form will have closed at that point and the app will exit.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|