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!
:confused:
Printable View
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!
:confused:
What 'End' you are talking about?
sorry! should have made myself more clear
orCode:Private Sub MenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem5.Click
Me.Close()
End Sub
Code:Private Sub MenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem5.Click
End
End Sub
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.
or
VB Code:
Application.Exit()
There is also:
Application.ExitThread()
Environment.Exit(-1)
System.Threading.Thread.CurrentThread.Abort()
Just to confuse even more! :D