CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2001
    Location
    Washington State, USA
    Posts
    3

    Halt QueryUnload Event

    During the QueryUnload event I want to *stop* VB from shutting down the program.

    For example. The user clicks the corner 'X'. During the QueryUnload event I prompt the user with a YesNoCancel MsgBox. If the user hit's cancel I need to stop the QueryUnload event from actually shutting down the application.

    Any thoughts on how I can do this?

    --Lyle E. Dodge
    [email protected]

  2. #2
    Join Date
    Mar 2000
    Location
    Sheffield, UK
    Posts
    52

    Re: Halt QueryUnload Event

    Try this:

    Dim strReply As String

    strReply = MsgBox("End?", vbYesNo)

    If strReply = vbNo Then 'User clicks no
    Cancel = True 'Dont end program
    Else
    Cancel = False 'End Program
    End If

    Cheers

    Rob


  3. #3
    Join Date
    May 2001
    Location
    Washington State, USA
    Posts
    3

    Re: Halt QueryUnload Event

    Rob,

    Beautiful! Thanks so much. I've been coding for years and figured I could nail this one so I was getting frustrated.

    In fact I was using Cancel = True elsewhere in the QueryUnload event but I was turning it False based on other conditions but I didn't realize that would affect the Event stopping or not.

    Anyhow. I *really* appreciate your tips. Worked perfectly, as you expected.

    --Lyle E. Dodge
    [email protected]

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

Featured