Results 1 to 2 of 2

Thread: msgbox when X button click

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2009
    Posts
    211

    msgbox when X button click

    hello

    Here is my code :
    Code:
    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Cancel = (MsgBox("Are you sure you want to quit? All your unsaved data will be erase.", vbQuestion Or vbYesNo, "Quit?") = vbNo)
    
    End Sub
    my concern is i want this message box appear everytime i click the X button on the window and its working.but the problem is even i unload my form and open another the msgbox still appear. I know that the logic of the code is when you unload the form this msgbox will appear. i want this msgbox appear when i click the x button only. pls help!

    thanks!

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: msgbox when X button click

    Add this check first....
    Code:
     If UnloadMode = vbFormControlMenu Then ' X clicked or Exit from system menu
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

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