terminating a program completely

how do u effectively terminate a vb program?
i created a program and it exits fine (i placed a button "exit").

the code is something like this :

sub cmd_ExitClick()
   end
end sub

of course it always exit whenever i press the exit button. but it leaves a zombie process (in unix term) in the task manager window. even its already closed. how do i effectively close/terminate it w/o leaving a track in the task man?. i stiil have to ctrl-alt-end-task the sucker.
LVL 3
iboAsked:
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.

mcriderCommented:
unload all of the forms that have been loaded before you terminate...  When you do that, your VB program should end without the END statement.

Cheers!
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
JuiletteCommented:
Mcrider is correct...you shouldn't use End.
If you need the code to supplement his answer, here it is.

'create a bas module
'
Public Sub UnloadAllForms()
      Dim Form As Form
               For Each Form In Forms
                        Unload Form
                  Set Form = Nothing
         Next Form
End Sub

'
'==================================================
'place this in your exit event
'
      Call UnloadAllForms
0
mark2150Commented:
You also want to shut down any timers, close all files and databases as well.

M
0
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!

iboAuthor Commented:
i only have one form.. the main form.
i didnt use gdi.

so..
its must be

sub my_exit
  unload Main_form
end sub

?
0
mcriderCommented:
Yes ibo, you got it!
0
JuiletteCommented:
Unload Me
'saves typing form name
'Me refers to active form and since you
'ony have one...you got it.
0
mark2150Commented:
Actually the form shown in juliette's first example is preferred. You can use it as a common routine and it will work with any number of forms, including just one. Since it automatically adapts as forms are added you never have to fiddle with it in later versions of your program where you might actually add a new form. The execution difference doesn't matter since this is a one-time use routine at shutdown.

The only modification I would make to Juliette's code is that using a keyword as a variable name is considered a no-no. Instead of;

DIM FORM AS FORM

I'd code:

DIM FRM AS FORM

This will help the compiler keep things straight and you loop becomes:

FOR EACH FRM IN FORMS
  UNLOAD FRM
  SET FRM = NOTHING
NEXT FRM

M
0
mcriderCommented:
It doesn't matter whether you use Unload Me, Unload Main_form, or a for each unload...

As long as you unload all of forms that you have loaded.

Cheers!
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.