-
April 15th, 2004, 02:36 AM
#1
*.exe problem ?
I have completed my project and make a *.exe for the VB program.
There is no problems with the functions of *.exe.
The pronblem is that when i have exited the *.exe, inside the task manger , the *.exe is still running.
It is any good idea to terminate the *.exe completely.......
Sami.
-
April 15th, 2004, 03:14 AM
#2
You may have forms still loaded....
Write an exit point for the application in a standard module...in this exit routine, destroy all global variables and every form in the forms collection...
eg;
Code:
Public Sub UnloadApplication
Dim frm As Form
Set g_myObject = Nothing
For Each frm in Forms
Unload frm
Set frm = Nothing
Next
End Sub
Just call this routine when you application is going to close...
-
April 15th, 2004, 07:22 AM
#3
End statement...
Hi sami1983,
This Sub can be replaced by simple End statement
For example:
Code:
Public Sub UnloadApplication()
End
End Sub
End statement unloads all active(loaded) forms.
Regards,
Jovan
Last edited by Jovan; April 15th, 2004 at 07:25 AM.
-
April 15th, 2004, 08:14 AM
#4
You shouldn't use the End statement to terminate a program. There is somthing in your program that is keeping it from unloading properly. I've seen this happen with sub-forms, database connections and Crystal Reports. Using the End statement can lead to corrupt data in your database (if you're using one) and other maladies caused by the improper termination of an object without releasing its dependencies (memory leak.) The proper solution is to unload *everything* in the Form_QueryUnload event procedure. Then the application will end on the when the Unload event has completed. If you're using the .Hide method on a sub-form then that is likely the culprit.
-
April 15th, 2004, 08:15 PM
#5
Thanks a lot all guys here.
The problem has been solved.It was due to some some hiden forms that i had not closed yet.
Sami.
-
April 16th, 2004, 02:04 AM
#6
Hi, Dmorley. The Sub given by u works perfect, but one thing that:
Sometimes, the user exit the form just by closing it rather than go through by pressing "Exit" button.
If they do in such way, the Sub will not be called and the *.exe is still running.
Hope that u can get what i mean.....
Thanks..
Sami
-
April 16th, 2004, 02:54 AM
#7
Sami,
Don't call the UnloadApplication routine directly from the cmdExit_Click event, instead call it from the Form_Unload or Form_QueryUnload events.
In cmdExit_Click, you can just write something like...
Unload Me
And then...
Private Sub Form_Unload
Call UnloadApplication
End Sub
This way, if your user clicks on Exit or if they close the window using the X button, the UnloadApplication routine is always called...
Hope that helps...
-
April 19th, 2004, 03:20 AM
#8
That's what i need......
Thanks for ur kindly help, Dmorley.
-
April 22nd, 2004, 10:41 AM
#9
a note: avoid calling it motre than once...
In main form:
Code:
Private sub Query_Unload(....)
Dim frm As Form
Set g_myObject = Nothing
For Each frm in Forms
'avoid calling this code from here!
If frm.Hwnd<>me.Hwnd then
Unload frm
'Set frm = Nothing 'do not need this, but you could keep it
End If
Next
end sub
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
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
|