|
-
Jan 15th, 2004, 08:56 AM
#1
Thread Starter
Addicted Member
Window objects not clossing after unload
After I unload my project the application doesnt close. ie when you go to task manager you can still see the app running. Is there a function available in VB that can do this or what other method can i use. (Im ussing a mdi with child forms & even if i unload each object in script the project still doesnt close)
-
Jan 15th, 2004, 02:01 PM
#2
The program won't shutdown completely because some object some where still contains a valid reference and has not been terminated.
Make sure all objects are terminated using Set ObjectName = Nothing. Also, if the object requires it, call its Close or Quit method.
For example, the following code will cause a hidden instance of Microsoft Word to be created everytime this program is executed. Every instance of Word will remain active, even though we set the object to nothing, until the computer is rebooted or MS Word is opened and then closed. This is because the Word object requires a call to its Quit method.
The point is make sure you terminate all object instances properly. Don't rely on VB to handle everything.
VB Code:
Option Explicit
Private objWord As Word.Application
Private Sub Form_Load()
Set objWord = New Word.Application
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set objWord = Nothing
Set Form1 = Nothing
End Sub
For those who are thinking of suggesting it, using End in this case will not close the runaway MS Word process.
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
|