Hi,
How do I close my VB programs the right way?
When you use the end statement or the set ...= nothing I alsways see that the program is still in the memory.
This is done by Ctrl+Alt+Del.
Does somebody nows the answer.
Thanks...
Printable View
Hi,
How do I close my VB programs the right way?
When you use the end statement or the set ...= nothing I alsways see that the program is still in the memory.
This is done by Ctrl+Alt+Del.
Does somebody nows the answer.
Thanks...
I think the proper command is: Unload Me
Actually the best way to completely close the program is to put End in the form unload
For closing your programs try this:
<code>
'use this in your unload event
Dim Form As Form
For Each Form In Forms
Unload Form
Set Form = Nothing
Next Form
</code>
There are many different ways and every one is allowed their own opinion, i tend to use unload me because i have used end before and when i have a lot of forms is still leaves some active and the program doesn't fully close
so i would use
Unload me
Merlin ?
Set Form = Nothing - Clears up any resources a form is using.
Unload Me - Unloads a form or control from memory.
End - Terminates execution. Never required by itself but may be placed anywhere in a procedure to close files opened with the Open statement and to clear variables.
I usually use all of them. End is not usually good by itself, nor is setting the form to nothing. Unload Me will work by itself well. But for less confusion and fustration, include all of them :rolleyes:.Code:Public Sub UnloadAllForms()
Dim Frm As Form
For Each Frm In Forms
Unload Frm
Set Frm = Nothing
Next Frm
End
End Sub
'Usage:
Call UnloadAllForms
If you have a VB Module Prog, the proper way to end is:
Exit Sub
For a console program:
FreeConsole <API>
But if it's too many nested procedures, consider using
End
because ELSE it gets complicated.
Quote:
Originally posted by Escaflowne
If you have a VB Module Prog, the proper way to end is:
Exit Sub
For a console program:
FreeConsole <API>
But if it's too many nested procedures, consider using
End
because ELSE it gets complicated.
Exit Sub - Immediately exits the Sub procedure in which it appears. Execution continues with the statement following the statement that called the Sub.Quote:
If you have a VB Module Prog, the proper way to end is:
Exit Sub
It does not End the program. And, from VB itself:
Quote:
End - Terminates execution. Never required by itself but may be placed anywhere in a procedure to close files opened with the Open statement and to clear variables.
I agree with Tomexx on this one. However, remember to name your variables properly. Change Form to something else as it is already in use by VB.
Finished reading up on this...had a project which even when closed didn't release all resources
= nothing.......is spot on
But...........
They claim the me suffix to unload shouldn't be used, rather the actual form name should be used. Any one else have an opinion on this???????