whosyodaddy Posted June 25, 2003 Posted June 25, 2003 how do you make it so that lets say you click on "Food" in the MainMenu on Form1, then Form2 comes up. And then when you click on the button OK on Form2, Form1 and Form2 quits?:confused: :D Quote
*Experts* Volte Posted June 25, 2003 *Experts* Posted June 25, 2003 You need to modify the constructor of Form2 (that's the New() sub) to accept a form as a parameter. So modify it to look like this:Public Sub New(caller As Form) MyBase.New() InitializeComponent() m_fCaller = caller ' You must define m_fCaller as a class level variable first End SubThen, when you create the form on Form1, do this:Dim f2 As New Form2(Me) f2.Show()When you wish to close both forms, in Form2, do this:m_fCaller.Close() Me.Close() Quote
Mehyar Posted June 26, 2003 Posted June 26, 2003 VF that's absolutely correct if you still want to do work in the application , but if whosyodaddy wants to just quit the application he can simply use End Quote Dream as if you'll live forever, live as if you'll die today
Administrators PlausiblyDamp Posted June 26, 2003 Administrators Posted June 26, 2003 Just out of interest is 'End' still considered as bad as it was in VB6? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Grimfort Posted June 26, 2003 Posted June 26, 2003 Remarks The End statement can be placed anywhere in a procedure to end code execution, close files opened with an Open statement, and clear variables. The End statement calls the Exit method of the Environment class in the System namespace. System.Environment.Exit requires that you have SecurityPermissionFlag.UnmanagedCode permissions. If you do not, a SecurityException error occurs. When executed, the End statement clears all variables at module and class level and all static local variables in all modules. Note The End statement stops code execution abruptly, without invoking the Finalize method or any other Visual Basic code. Object references held by other programs are invalidated. The End statement provides a way to force your program to halt. For normal termination of a Visual Basic program, you should unload all forms. Your program closes as soon as there are no other programs holding references to objects created and no code executing. With an additional keyword, End delineates the end of the definition of the appropriate procedure or block. Quote
Administrators PlausiblyDamp Posted June 26, 2003 Administrators Posted June 26, 2003 I'll consider that as 'just as bad' then ;) I always avoided it in VB6 because of the way it abruptly ended a running app, seems like it does the same in .Net. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Grimfort Posted June 26, 2003 Posted June 26, 2003 Sometimes it does have its uses, if your program hits a critical error, then you can show the error, run End, then it wont run things like any save code you have in your Exit events. Which means the next time your app loads, it will actually load :). Quote
Mehyar Posted June 26, 2003 Posted June 26, 2003 Thanks for the info guys Quote Dream as if you'll live forever, live as if you'll die today
whosyodaddy Posted June 26, 2003 Author Posted June 26, 2003 ok Thanks :) , i will try these codes in a little bit.;) Quote
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.