Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Application holding on to reference..
Message
General information
Forum:
Visual Basic
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00715586
Message ID:
00715995
Views:
7
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
    Map
    View

    Click here to load this message in the networking platform