Using End()

J

Jim Edgar

I'm relatively new to this group so I apologize if this topic has been tossed around
before. I'm transitioning from VB6 to VB.net and I've been reading and working through
examples in a Microsoft Press book. In all of the examples the author uses End() to exit
the program. In VB6 it is unacceptable to use End because the program suddenly terminates
and no "clean up" occurs. In VB6 I use code like:

Private Sub cmdClose_Click()
Unload Me
End Sub

Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
Dim f As Form
For Each f In Forms
Unload f
Set f = Nothing
Next
End Sub

Is there anything similar in .Net or is the use of End() acceptable?

Jim Edgar
 
H

Herfried K. Wagner [MVP]

Jim Edgar said:
I'm relatively new to this group so I apologize if this topic has been
tossed around
before. I'm transitioning from VB6 to VB.net and I've been reading and
working through
examples in a Microsoft Press book. In all of the examples the author
uses End() to exit
the program. In VB6 it is unacceptable to use End because the program
suddenly terminates
and no "clean up" occurs. In VB6 I use code like:

Private Sub cmdClose_Click()
Unload Me
End Sub

Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
Dim f As Form
For Each f In Forms
Unload f
Set f = Nothing
Next
End Sub

Is there anything similar in .Net or is the use of End() acceptable?

You'll have to close your forms by calling their 'Close' method. Normally,
closing the main form (the form the application's message pump is associated
with) will close the application, and cleanup code will be executed. I
would try not to use 'End' because it gives you few control about what's
done when exiting your application -- in other words, the reasons to avoid
using 'End' in VB still apply to VB.NET.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top