cj said:
What is the difference between using Me.close vs. End to stop the
execution of a program?
Even more so than in earlier incarnations of VB, you *should not use
End*. This is from the docs (my emphases):
The End statement stops code execution abruptly, **without invoking the
Dispose or Finalize method**, or any other Visual Basic code. Object
references held by other programs are invalidated. **If an End
statement is encountered within a Try or Catch block, control does not
pass to the corresponding Finally block.**
Because End terminates your application without attending to any
resources that might be open, **you should try to close down cleanly
before using **it. For example, **if your application has any forms
open, you should close them before control reaches the End statement.**
**You should use End sparingly, and only when you need to stop
immediately.** The normal ways to terminate a procedure (Return
Statement (Visual Basic) and Exit Statement (Visual Basic)) not only
close down the procedure cleanly but also give the calling code the
opportunity to close down cleanly. A console application, for example,
can simply Return from the Main procedure.
**Security Note
The End statement calls the Exit method of the Environment class in the
System namespace. Exit requires that you have UnmanagedCode permission.
If you do not, a SecurityException error occurs.**
I've been using me.close and putting code in the form.closing event to
make sure things are stopped before the program execution stops. This
has been working for me even when the startup is sub main perhaps
because my sub mail usually looks like
<STAThread()> Public Sub main(ByVal CmdArgs() As String)
Dim mainForm As New Form1
Application.Run(mainForm)
End Sub
What you are doing is the right way to do things.