Results 1 to 10 of 10

Thread: Yes or No answer...

  1. #1

    Thread Starter
    Addicted Member Dementia Freaks's Avatar
    Join Date
    Jun 2001
    Location
    Canada
    Posts
    132

    Cool Yes or No answer...

    In my program, I want a message box to appear, when the user hits "Exit". I have the message box, it asks if they are sure they want to quit. (Yes or No option) Here is the code of the message box:

    MsgBox "Are you sure you want to quit?", _
    vbQuestion + vbYesNo, _
    "Do you qant to quit?"


    The message box isnt the problem, its the answer. How do I make it so on Yes, it closes, and on No, it doesnt? I'd imagine it may be some kind of "if" statement but im not sure. Please responde if you may know!

  2. #2

    Thread Starter
    Addicted Member Dementia Freaks's Avatar
    Join Date
    Jun 2001
    Location
    Canada
    Posts
    132

    Cool Error in the code i gave...

    MsgBox "Are you sure you want to quit?", _
    vbQuestion + vbYesNo, _
    "Do you qant to quit?"


    Was the code i gave, there is a spelling error. It should read:

    MsgBox "Are you sure you want to quit?", _
    vbQuestion + vbYesNo, _
    "Do you want to quit?"

    Thats want, not qant! Sorry!

  3. #3
    Member bizzyVB's Avatar
    Join Date
    Jun 2001
    Location
    Florida
    Posts
    38
    heres how you do it!

    response = Msgbox("Are you sure you want to quit?",vbquestion + vbyesno,"Do you want to quit?")

    if response = vbyes then
    end
    elseif response = vbno then
    exit sub
    end if

    there it is!

  4. #4
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    Dim iRes As Integer
    iRes = MsgBox("Quit?", vbYesNo + vbQuestion)
    If iRes = vbYes Then End


    peet

  5. #5

    Thread Starter
    Addicted Member Dementia Freaks's Avatar
    Join Date
    Jun 2001
    Location
    Canada
    Posts
    132

    Cool It didnt work...

    That code, caused it only to close the message window, upon yes or no! i copied it and psted it, so there was no problem in writing it.

  6. #6
    Member bizzyVB's Avatar
    Join Date
    Jun 2001
    Location
    Florida
    Posts
    38
    whose code doesnt work?

    i'm sure my code works.

    response = Msgbox("Are you sure you want to quit?",vbquestion + vbyesno,"Do you want to quit?")

    if response = vbyes then
    end
    elseif response = vbno then
    exit sub
    end if

    cya

  7. #7
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    hmm this works just fine....

    Dim iRes As Integer
    iRes = MsgBox("Quit?", vbYesNo + vbQuestion)
    If iRes = vbYes Then End


    peet

  8. #8

    Thread Starter
    Addicted Member Dementia Freaks's Avatar
    Join Date
    Jun 2001
    Location
    Canada
    Posts
    132

    Cool peet's worked...

    Peet's code worked fine. The otherone didnt!:P

  9. #9
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    hmm ...

    bizzyVB's should work as well...


  10. #10
    Addicted Member machine_wars's Avatar
    Join Date
    Dec 2000
    Location
    NC
    Posts
    147
    Code:
    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
        
    Dim mres As VbMsgBoxResult
     
    mres = MsgBox("Are you sure you want to quit?", vbYesNoCancel Or vbExclamation, "My Application")
      
      Select Case mres
        Case vbYes
            'User wants to save file
            Save_File
        Case vbNo
          'Program ends, no save.
            Cancel = False
        Case vbCancel
          'Cancel the exit, app stays running.
            Cancel = True
      End Select
    End Sub

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