Do you have mulitple forms in the program and if so are you using
Form2.Hide
This will make to form go away but not unload
Unload Form2
or
Unload Me
Main Topics
Browse All Topicsalot of times when i make a program and if u hit the X at the top to close it, the form will go away but if u hit control alt delete, u can see that its still running..... how can i make it close all the way when the X is hit ?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Dear Jankhead,
Let 's try to copy this code into your VB Project.
'Note. you need to add another CommandButton into your form.
Option Explicit
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Form_Terminate()
MsgBox "Terminate"
End Sub
Private Sub Form_Unload(Cancel As Integer)
MsgBox "Unload"
End Sub
You could see that whenver you push the CommandButton or click at the X Button, you would see the MessageBox "Unload" first and then follow with MessageBox "Terminate". That 's mean if you wish to guarantee that this form have been unloaded completely. You have to check it at the event Form_Terminate.
Meng
to yodant and otehs suggesting using
END
to terminate a program. That is VERY VERY VERY VERY (get the idea) BAD advice.
Yes, End will cause the program to end - rather ABRUPTLY. Using End to terminate a program is EXACTLY equivalent to stopping your car, by smashing is, at full speed, into a BRICK wall, because you are too lazy (or don't know how) to apply the brakes, and the turn off the ignition.
Both techniques STOP the CAR, but the first technique is VERY BAD for anyone who might happen to be sitting in the car at the time. So too with using END. Yes, the program stops, but ALL memory allocations (such as open files, database connections, whatever) are NOT cleaned up, and that can have potentially serious consequences for your computer. NEVER use END, for any purpose. If you program is left in memory, there MUST be a reason, and when you find out what that reason is, and reslove hat, then th program will terminated properly.
AW
Keep it tidy. Remember collections?
Dim frm as Form
For Each frm in Forms
Unload frm
Next
This is what MSDN (in one place. It's mentioned quite a bit more. Investigate yourself if you must).
"The End statement ends an application immediately: no code after the End statement is executed, and no further events occur. In particular, Visual Basic will not execute the QueryUnload, Unload or Terminate event procedures for any forms. Object references will be freed, but if you have defined your own classes, Visual Basic will not execute the Terminate events of objects created from your classes."
If this is not reason enough to not use End, then I'm not quite sure what would be.
jankhead:
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations! No comment means you don't care.
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
-->Accept drpunk's comment as Answer
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER
GPrentice00
Cleanup Volunteer
Business Accounts
Answer for Membership
by: prasitleePosted on 2003-05-31 at 01:28:56ID: 8619361
Dear Jankhead,
You could check by adding the following sub into your form.
Private Sub Form_Terminate()
MsgBox "The form is closing"
End Sub
Whenever, the user click at the X Button, this event will be fired.
I am not sure if I answer you correctly, If not, please provide me more details.
Meng