Results 1 to 6 of 6

Thread: End Command

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2002
    Location
    Central US
    Posts
    183

    Question End Command

    What is the difference between End and Me.Close from what I was told in VB6 the Unload Me was the proper way of unloading a form.
    Someone care to explain?
    Thanks!

  2. #2
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    What 'End' you are talking about?
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Dec 2002
    Location
    Central US
    Posts
    183
    sorry! should have made myself more clear
    Code:
    Private Sub MenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem5.Click
            Me.Close()
        End Sub
    or
    Code:
    Private Sub MenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem5.Click
            End
        End Sub

  4. #4
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Me.Close closes the current form, if this form controls the life cycle of the application then the application is closed too, but End terminates execution immediately.


    Remarks from MSDN

    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. Your program closes as soon as there are no other programs holding references to its objects and none of its code is executing.

    If your application has any forms open, you should close them before executing End. A console application can either use End or simply return from the Main procedure.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    or
    VB Code:
    1. Application.Exit()

  6. #6
    Fanatic Member VBCrazyCoder's Avatar
    Join Date
    Apr 2003
    Posts
    681
    There is also:
    Application.ExitThread()
    Environment.Exit(-1)
    System.Threading.Thread.CurrentThread.Abort()

    Just to confuse even more!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width