General information
Category:
Coding, syntax & commands
Jose,
All form references need Set [FormName] = Nothing in the formUnload event. The reason is that VB creates a hidden variable reference with the same name as the Form; as long as the variable is set to the form object, your application won't terminate.
Still, in complex applications sometimes an object is overlooked, although I have long suspected a few bugs in VB in that area.
Another way to make sure the application terminates is to use the ExitProcess call:
Public Declare Sub ExitProcess Lib "kernel32" (ByVal uExitCode As Long)
ExitProcess 0
That will unload the application for sure.
HTH,
Ed VanDuyne
>>I have added this code to the Form Terminate and Form Unload Events.
>>Unload Me
>>I was under the impression that this would remove the reference to the application.
>>I ran into this issue:
>>After the user closes the application...I try to copy the new Executable into the source folder... I get "FILE MAY STILL BE IN USE " error.....
>>
>>Is there something else I need to do?
>
>Hi Alvin
>
>"Unload Me" is not necessary in those events (BTW, those events will never be called unless the form is already being unloaded)
>
>There must be another problem in your application which causes the EXE to remain in memory when the main window has been closed (you can verify that with the Task Manager)
>
>Posible causes are:
>
Circular references in objects you created (i.e. child holding parent reference)
>Me.Hide (instead of Unload Me) in a "Close" button
>Waiting loops on Sub Main or other module which calls the main form
>..others I can't figure! :o(
>
>Hope this helps,
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only