Results 1 to 13 of 13

Thread: ***INSTANTLY RESOLVED***Closing program (THANKS HACK!)

  1. #1

    Thread Starter
    Frenzied Member mxnmx's Avatar
    Join Date
    Dec 2001
    Location
    I'm back...now!!!
    Posts
    1,396

    ***INSTANTLY RESOLVED***Closing program (THANKS HACK!)

    I have this code in the close command button that is supposed to close the program

    VB Code:
    1. Private Sub cmdCloseProgram_Click()
    2. Unload me
    3. Set frmItem=Nothing
    4. Set frmOrder=Nothing
    5. End Sub

    When I use this button to close the program, it closes well & I cant see the program running in the Task Manager- Processes Tab but when I close the program by pressing [X] button on the upper right corner of the form, it keeps running in the back ground and I can see it thru Task Manager..Any Idea, how I can rectify this?
    Last edited by mxnmx; Nov 11th, 2002 at 08:46 AM.
    Can't Remember Birthdays or Important Dates- Never Miss any Important Date(s)

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Move you close code to the Unload event of your main form. When you close the form via the X button, your code is not being processed.

    If you run it from the unload event, no matter how the user closes the form, your code will run.

  3. #3
    PowerPoster
    Join Date
    Aug 2000
    Location
    India
    Posts
    2,288
    Move the Nothing part to Query_Unload
    VB Code:
    1. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    2.     Set frmItem = Nothing
    3.     Set frmOrder = Nothing
    4. End Sub

  4. #4
    Addicted Member
    Join Date
    Mar 2002
    Location
    Lithuania
    Posts
    165
    Private Sub cmdCloseProgram_Click()
    Unload me
    Set frmItem=Nothing
    Set frmOrder=Nothing
    '== = Thets you need ===
    End
    '==================
    End Sub
    P.S. Sorry for my poor English...

  5. #5

    Thread Starter
    Frenzied Member mxnmx's Avatar
    Join Date
    Dec 2001
    Location
    I'm back...now!!!
    Posts
    1,396
    Thanks Hack!!!!
    Can't Remember Birthdays or Important Dates- Never Miss any Important Date(s)

  6. #6
    PowerPoster
    Join Date
    Aug 2000
    Location
    India
    Posts
    2,288
    GameBit, if he closes his form through the "x" button at the top, your code will not be executed. Also, try to avoid "End" statements as far as possible.

  7. #7
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by GameBit
    Private Sub cmdCloseProgram_Click()
    Unload me
    Set frmItem=Nothing
    Set frmOrder=Nothing
    '== = Thets you need ===
    End
    '==================
    End Sub
    Using 'End' leads down the path to the dark side. So don't ever use it. mkay?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  8. #8
    Hyperactive Member LeeSalter's Avatar
    Join Date
    Oct 2002
    Location
    Notts, England
    Posts
    307
    Maybe add the following code to the Exit App event:-

    VB Code:
    1. Dim f as Form
    2. For each f in Forms
    3.      Unload f
    4. Next

    This will ensure each form is unloaded cleanly.
    "I'm Brian and so is my Wife"

  9. #9
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    Originally posted by The Hobo
    Using 'End' leads down the path to the dark side. So don't ever use it. mkay?
    I thought we declared it was ok to use End after u'd unloading and set the forms to nothing?
    Don't Rate my posts.

  10. #10
    Hyperactive Member RealNickyDude's Avatar
    Join Date
    Nov 2002
    Location
    Watching you through the hidden camera :o
    Posts
    435

    Talking

    VB Code:
    1. Dim f as Form
    2. For each [b]f in Forms[/b]
    3.      Unload f
    4. Next
    *lol*

    We all get upset, but no need to take it out on the poor forms
    [vbcode]
    On Error GoTo Hell
    [/vbcode]:¬) Nicky : Why not try VBCodebook.NET.

  11. #11
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by Pc_Madness
    I thought we declared it was ok to use End after u'd unloading and set the forms to nothing?
    Who are you including in this 'we?' I never remember declaring anything of the sorts.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  12. #12
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    Those threads we had in the past about this topic... I'll see if I can find them...
    Don't Rate my posts.

  13. #13
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    http://www.vbforums.com/showthread.p...t=Unload+Forms

    I think this is the one I'm talking about...
    http://www.vbforums.com/showthread.p...t=Unload+Forms


    By we.. I meant the forum.
    Don't Rate my posts.

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