Unload equivalent

I have just picked up VB 2005 Express and made the mistake of thinking I could brush up quickly on some old VB6 skills and get a simple program coded quickly. I have, what to me is a fairly basic question. How do you code an "Exit" button. In VB6, the code was simple - "Unload Me". What is the VB.NET equivalent

Help please!!!!



Answer this question

Unload equivalent

  • MilanG

    Exactly, although if you're talking about the startup form, close() does eventually cause dispose to be called.

    Dispose() will release all resources allocated to a form...although letting the form go fully out of scope will do the same as well.

    For the most part, Close() will be the method you'll call. I just wanted to present all the alternatives I knew of.

    Michael



  • 175726

    Thanks, both of you. I knew that there had to be something, but could not see it at all. I looked up the web pages which listed the changes from VB6, and unload wasn't listed there at all, but any search I did for unload seemed to come back to VB6 or VBA.

    What is the difference between close and dispose. I am presuming that dispose clears out the memory allocations as well as shutting the form down, whereas close leaves the code in memory for a quick start if it is required again.

    thanks for your help.


  • Prashweenet

    In VB 6 the Unload method would close the form from which it was being called - in VB 2005 the behavior is slightly different.

    me.Close() will close just the form it is being called from, unless it is being called from the StartUp form, in which case it will close the application.

    Application.Exit will close the entire application no matter where you call it from.

    So to unload a secondary form use me.Close; to unload the application use Application.Exit

    Hope this helps,

    Steve Hoag

    Visual Basic Express



  • Nanda_zrh

    me.Close()

    me.Dispose()

    Application.Exit()

    All of these will close the application (if the form you're calling close/dispose on is the main form). Application.Exit is the surefire way to close the application.



  • Unload equivalent