• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 147
  • Last Modified:

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.
0
stephenhoang
Asked:
stephenhoang
  • 3
  • 2
  • 2
  • +3
1 Solution
 
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
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

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 3
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now