|
-
Dec 2nd, 2004, 06:33 AM
#1
Thread Starter
Lively Member
best way to TOTALY kill an App???
What is the BEST way to Totally Kill an app Unload Me stil somtimes leaves an app running in the background
What the best way to kill EVERYTHING in an App compleatly ??
So Many things to do.....
So little enthusiasm to do them.
-
Dec 2nd, 2004, 06:37 AM
#2
Obear
You need to unload anything that you have loaded into memory inside the program by setting all objects to nothing and unloading all loaded forms.
i.e Set object = Nothing
-
Dec 2nd, 2004, 07:13 AM
#3
Addicted Member
Here's what i use:
VB Code:
Dim frmForm as Form
'Unload all forms
For Each frmForm In Forms
Unload frmForm
Set frmForm = Nothing
Next
'Kill app
End
Unloads all forms and sets them to nothing, and finally ends the app.
-
Dec 2nd, 2004, 09:24 AM
#4
Frenzied Member
You might want to add object unloading iside that loop as well
Something like
VB Code:
For Each object in frmForm
Set obj = nothing
Next
-
Dec 2nd, 2004, 09:42 AM
#5
Frenzied Member
setting each object to nothing is unnecessary: setting their container is good enough
this will get the job done well
VB Code:
Private Sub mnuExit_Click()
Unload Me
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub Form_Unload(Cancel As Integer)
Unload Form2
Set Form2 = Nothing
Set Form1 = Nothing
End
End Sub
-
Dec 2nd, 2004, 11:00 AM
#6
2 things. Never use END.
It's sloppy, and if something isn't unloaded correctly, then the END command just ignores it, no Unload or Terminate events will fire.
I have just removed the END command from our works app, after pestering my boss for 12 months about it.
Guess what...once I did the app fell over all over the place because we, sorry, previous developers had not tidied up their code properly.
It's taken me 24hrs to fix this, but now things are terminated correctly.
There should NEVER be a need to use the END command.
It's almost as bad as NOT using Option Explicit 
Also, never access the forms directly. IE:
Never do:
VB Code:
Private Sub cmdShow_Click()
ShowForm
End Sub
Private Sub ShowForm()
Form2.Show
End Sub
This can lead to sticky situations where previous varibles were not cleared properly etc.
What you should do is:
VB Code:
Private Sub cmdShow_Click()
ShowForm
End Sub
Private Sub ShowForm()
Dim frmNew As Form2
Set frmNew = New Form2
Load frmNew
frmNew.Show
Set frmNew = Nothing
End Sub
This gives you way more power in coding, plus it's a lot neater and you won't get tied up with forms not going out of scope properly.
Wooka
-
Dec 2nd, 2004, 11:42 AM
#7
Frenzied Member
don't use end to acutally do the program close, but using it in Form_Unload add even more 'closure'
believe me if i thought it was just overkill i wouldn't use it, but i've seen it make a difference
-
Dec 2nd, 2004, 11:52 AM
#8
Originally posted by dis1411
don't use end to acutally do the program close, but using it in Form_Unload add even more 'closure'
believe me if i thought it was just overkill i wouldn't use it, but i've seen it make a difference
Sorry, disagree.
There is NEVER any reason to use END.
Why do you use END? Have you got a valid reason to?
END is evil, and using it for more "closure" is a bad excuse and leads to sloppy coding, and/or, hides potential errors that have not been dealt with correctly 
Woka
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
|