Results 1 to 6 of 6
  1. #1
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Long Beach, California, USA
    Posts
    1,912
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Closing a program after it has 'Run' (VB6)

    DUH! Yet another dumb question...

    Edit: Even dumber than I thought. I simply left out the space.

    IGNORE THIS THREAD!

    Sorry...

  2. #2
    4 Star Lounger
    Join Date
    Aug 2002
    Location
    Dallas, Texas, USA
    Posts
    594
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing a program after it has 'Run' (VB6)

    What space....to end a VB program, you use the command END (No space)

  3. #3
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Long Beach, California, USA
    Posts
    1,912
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing a program after it has 'Run' (VB6)

    Well, that is not what my simple education has taught me:

    "If you specified a form as the Startup object, then you must unload this form to close the application. You can do this by including the following statement...

    Unload Me"

    So... I left out the space before "Me". When I put the space in, it works as expected and my program closes.

    ________

    Alternatively -

    "If you specified a Sub Main procedure as the startup object, the program terminates when the Sub Main proceudre is completed. For example,

    Sub Main()
    ...
    End Sub

    In my case, I believe I want to use "Unload Me" -- and it does work the way I want it.

    However, I would be happy to learn how I could use "END" instead. How can I use END before the End Sub line? Or do I just leave out the End Sub and simply put "END"?

  4. #4
    4 Star Lounger
    Join Date
    Aug 2002
    Location
    Dallas, Texas, USA
    Posts
    594
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing a program after it has 'Run' (VB6)

    In a very simple VB application, what you have stated does work. If you have one form, and you unload that form, you're program is done. If you have just a module with Sub Main() in it, yes, when it hits End Sub, your application is done.

    However, if it is more then one module or one form, neither of those is going to completely close your application.

    For instance:

    Sub Main()
    frmMain.Show
    frmSecond.Show
    End Sub

    Now you're program doesn't stop after the End Sub, because frmMain and frmSecond are loaded.... Also, it does not stop when either form is unloaded, only when both forms are loaded. However, if you had a command button on frmMain, titled Exit:

    Sub cmdExit_OnClick()
    End
    End Sub

    When that button is clicked, your code unloads itself, and your application stops, no matter what you have open!

  5. #5
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Long Beach, California, USA
    Posts
    1,912
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing a program after it has 'Run' (VB6)

    Got it. Thanks.

    Noted typo: "only when both forms are UNloaded." -- but easy to figure out.

  6. #6
    4 Star Lounger
    Join Date
    Aug 2002
    Location
    Dallas, Texas, USA
    Posts
    594
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing a program after it has 'Run' (VB6)

    Whoops....I either need more coffee or a beer! <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •