How do I terminate my running application?

Hi ya'll,
   I compiled my program and then run the EXE, and when I quit the program it is gone.  But the thing is it is still running in the background (I checked for it using task manager).  On the quit button I used Unload Me.  How can I "kill" the program completely so it will release the database it connected to.
 Thanks,
Stephen.
stephenhoangAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

VbmasterCommented:
Try putting this code in the Unload event of your main form..

  For Each Form In Forms
    If Not (Form Is Me) Then
      Unload Form
    End If
  Next
  Unload Me

0
AnswerTheManCommented:
you should close all your database objects and set them to nothing.
there is probebly more but having no code of yours, what can one say ?
0
barnackyCommented:
Not a very graceful solution, but have you tried END.  I agree, you should unload all your forms and release all your database variables.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

manojaminCommented:
END should work. If that does not, try ExitProcess API call with the exit code 0.

If that does not work also, that means somewhere in your application (or in the calld extrenal function(s)) there are other threads running. This will make your VB app to go but the process will not be terminated until all the threads exits. In this case try using TerminateProcess API.

Hope this helps you...
0
stephenhoangAuthor Commented:
Thanks a bunch to all of you.
  I gave barnacky the points because barnacky is the first one to suggest the magic word END and it worked for me :)
Steve.
0
VbmasterCommented:
The reason noone suggested END is that it's NOT a command that is to be used whenever the program doesn't correctly shut down, since it does not clear memory used by the program..
0
VbmasterCommented:
Oh sorry, misread it somewhat, thought manojamin's answer was accepted as the answer, but now I c that barnacky mentioned the right way to do it when he told you to use the end statement.
0
AnswerTheManCommented:
i admit that sometimes i make the sin of using the END too, but that is only on my "QUICK AND DIRTY" experiments.
giving what seems to be a beginer this solution will make him a lousy programmer, who'll never know how to terminate processes since he have the MAGIC WORD as he already said...
if it was really magic - fine. that's RAD, but it is not. i'd like to see this word cleans a rowbust DCOM solution with hundreds of objects around.
0
SirNickCommented:
You can try using 'END' but if you have a number of different forms open and they are not in the Taskbar you may have the same problem.
0
barnackyCommented:
As I stated earlier, END is not a graceful solution.  Unloading all the forms with an IsLoaded function, terminating any processes, and releasing all (database) variables is a much better solution.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.