yaniv Posted May 21, 2003 Posted May 21, 2003 Well, i think that i understood that i have to create a new object to open form and then i use the object to close the form, but can i close the main form (the start page)? Quote
wyrd Posted May 21, 2003 Posted May 21, 2003 C# - this.Close(); VB - Me.Close() Quote Gamer extraordinaire. Programmer wannabe.
yaniv Posted May 21, 2003 Author Posted May 21, 2003 it's doesn't work. this is my code: (i want the button to open the new form and to close the menu) private sub button1_click dim frm as new form1() frm.show() me.close end sub and it does't work, the me.close is closing (as i see it) the new form. Quote
yaniv Posted May 21, 2003 Author Posted May 21, 2003 well, i discovered that when i use the me.close and close the main form i just closing the all program. what i"m looking for now is a way to close the main form while the second one is open and to reopen it when i close the second. what i did is to use sub main to create te main form, and i can now hide it, but when i"m in the second form, i can't find the way to recognize the main form. i just can't give him a name that the second form recognize. do you idea? Quote
Guest mutant Posted May 21, 2003 Posted May 21, 2003 Did you dim the form as Public in your sub main? Quote
wyrd Posted May 22, 2003 Posted May 22, 2003 What about Application.Exit() ? Quote Gamer extraordinaire. Programmer wannabe.
yaniv Posted May 22, 2003 Author Posted May 22, 2003 You can't public a form in a shared sub (which is the 'main' sub). application.exit is closing the entire program. Quote
*Gurus* divil Posted May 22, 2003 *Gurus* Posted May 22, 2003 You need to modify your sub main (or create one if you don't already have one) and use Application.Run() (note no parameters) to start an application-wide message loop that isn't dependant on any one form. The default behaviour is to have your message loop based on a main form, and therefore it shuts down when that form does. This will solve your problem, but introduce a new one - when you have a message loop that doesn't depend on one form, you must then manually call Application.Exit() when you really do want your application to close. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
wyrd Posted May 22, 2003 Posted May 22, 2003 Oh.. sounded like you were trying to close the entire program. Sorry. :) Quote Gamer extraordinaire. Programmer wannabe.
yaniv Posted May 22, 2003 Author Posted May 22, 2003 well i changed the sub main, but i do have to start with some form, no? so i used this code: Public Shared Sub main() Application.Run() Dim frm As New Form1() frm.show() End Sub but nothing happen!! i do think i miss something, it supposed to be simple, no? Quote
*Gurus* divil Posted May 22, 2003 *Gurus* Posted May 22, 2003 Show the form before the Application.Run() call, that ought to do it. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.