|
-
December 4th, 2002, 04:40 PM
#1
My program is still running when I exit???
Hi,
I have a VB program (with a form called "Form1"), and when I exit and I press CTRL-ALT-DELETE to bring up the applications and processes it says that it is still running.
In my exit button I have:
Unload Form1
Set Form1 = Nothing
Does this clear it from the memory??
Any info,
Thanks
Mark
-
December 4th, 2002, 05:22 PM
#2
Depends what you are doing. If you have a recordset open possibly its not closing at all. or a database connection. Perhaps you have a timer object still running (though i'm pretty sure they die when the form is unloaded).
One thing to do that i can't see you doing there is...
in your cmdExit_click put the following
Unload Me
In your form1_unload event put
Set form1 = nothing
see how that goes. Don't have any code after the unload me in cmdExit. If you have to make sure you have Exit Sub after it like this
Unload Me
Exit Sub
-
December 4th, 2002, 05:59 PM
#3
by referencing form1 after the unload, it recreates it, so don't do that. Instead, do this:
Unload Me
End
That should do it, but depending on other objects, you may have to take other steps.
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
-
December 4th, 2002, 07:20 PM
#4
Set form1 = nothing
doesn't actually recreate it. It actually just unreferences it freeing up the memory it took. Just a bit of garbage collection.
Don't ever use the End statement. This is not the way to end a program. End will cause the program to terminate and it may not unload properly or clean up after itself properly. This can cause more problems than its worth.
End will more than likely stop your thing in the Task list, but it may cause other problems along the way.
-
December 4th, 2002, 07:24 PM
#5
That's true what you say about End, but that is why I would only use it AFTER the unload. I only had one case so far that required it, and it worked well as I described. Still, I don't really like using it either, but it sounds like it may be needed here.
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
-
December 4th, 2002, 07:27 PM
#6
Yes WizBang is right. I had the same problem as you and when I did the:
Unload Me
End
No more problems!
-
December 4th, 2002, 07:30 PM
#7
I'll agree its a quick fix, but better would be to find out whats causing the problem and fix that, rather than just kill the thing.
Thats what i reckon anyway
-
December 4th, 2002, 07:50 PM
#8
Yes it is a quick fix, but I did all the forms with the Unload and it would still show the program in the task menu. Each form had an exit with Unload Me and just to be sure I had the Mian form also with the Unload for each form. Didn't close the program all the time and have no clue why so I ended up with the (End) in the Main form. I had DoEvents on one of the other forms and thought the Unload Me on the exit would work for that form.
-
December 4th, 2002, 08:40 PM
#9
unload problem
i had the same problem.
use this when exiting:
Dim frm As Form
Close
For Each frm In Forms
Unload frm
Next frm
also, if you run a for-next loop, be SURE to "exit for" instead of jumping out
xp was bad about not closing, i use the above code and i always
Exit For
-
December 5th, 2002, 12:05 AM
#10
-
December 5th, 2002, 09:12 AM
#11
-
December 5th, 2002, 01:24 PM
#12
Hello again,
10 Replies!!!
Got it working now, I just used:
Unload Me
End
Thanks for the Info.
Mark
Last edited by Mark2; December 5th, 2002 at 01:26 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|