|
-
Sep 29th, 2000, 11:38 AM
#1
Thread Starter
Junior Member
Sometimes when I end a VB program a process remain running in the background. How can I close a VB program and be sure that no threads or processes remain running? Is there any code I should have in the unload event or something?
-
Sep 29th, 2000, 12:13 PM
#2
A VB program ends after all of its forms have been unloaded, or when the "End" statement is executed.
"End" is a harsh way to end the application is generally not recommended.
Could it be that you hid, but did not unload a form? If so, the program may appear to have ended, but a form is still in memory.
Also, when you unload a form, setting it to Nothing will clear out any form-level variables that were declared in that form. In the Form_Unload event, I usually code:
Set Form1 = Nothing
"It's cold gin time again ..."
Check out my website here.
-
Sep 29th, 2000, 02:47 PM
#3
As a rule, I try to let VB execute as many of the program's events (when closing) as possible, this ensures that 'dirty' files are saved when necessary.
As Brucey says, just stopping the program isn't a good idea.
-
Sep 29th, 2000, 03:02 PM
#4
Fanatic Member
Try this code:
Code:
For Each Form In Forms
Unload Form
Next
-
Sep 29th, 2000, 03:51 PM
#5
Code:
Sub DestroyAll()
Dim frm As Form
For Each frm In Forms
Unload frm
Set frm = Nothing
Next frm
End Sub
Usage
Code:
Private Sub Command1_Click
DestroyAll
End Sub
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
|