Results 1 to 4 of 4

Thread: How do i make my program End when i hit the X button?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2006
    Posts
    22

    How do i make my program End when i hit the X button?

    when you hit the X button on the very top right, next to the minimize button i need the program to end.
    i know i did this the completly wrong but heres my rig so far.

    IF form1.Visable = FALSE THEN
    END

    and it only works sometimes LOL!

    please help

  2. #2
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How do i make my program End when i hit the X button?

    VB Code:
    1. Private Sub Form_Unload(Cancel As Integer)
    2.     Dim frm As Form
    3.     For Each frm in Forms
    4.         If Not frm Is Me Then Unload frm
    5.     Next frm
    6. End Sub
    Never use End.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2006
    Posts
    22

    Re: How do i make my program End when i hit the X button?

    I dont quite understand what that code does.
    i have a multi form project, but form1 is the main form, i dont mind if all other forms close with formX.Visable = false. but i need the entire program to shutdown and close when i hit the X button in the (main) form1.

    thanks though

  4. #4
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How do i make my program End when i hit the X button?

    That code goes in the main form, so when you unload the main form it loops through all the currently open forms and tells them to unload.

Posting Permissions

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



Click Here to Expand Forum to Full Width