Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
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
  • *Experts*
Posted
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 Sub

Then, 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()

Posted

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

Dream as if you'll live forever, live as if you'll die today
Posted

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.

Posted
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 :).

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...