Results 1 to 3 of 3

Thread: exiting problems[resolved]

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2003
    Location
    Michigan
    Posts
    101

    exiting problems[resolved]

    i want to do a msgbox that prompts the user to exit, or not. problem is, even when you click 'no,' you still exit.
    here's my code
    VB Code:
    1. Private Sub Form_Unload(Cancel As Integer)
    2. Dim m As Integer
    3.  
    4. m = MsgBox ("Are you sure you want to exit?", vbExclamation + vbYesNo, "Exit?")
    5.  
    6. Select Case m
    7.  
    8.     Case vbYes
    9.         Unload frmMain
    10.         Exit Sub
    11.     Case vbNo
    12.         Exit Sub
    13.  
    14. End Select
    15. End Sub

    what is wrong here?

    thanks d00dz
    Last edited by OsamaBinGhandi; Mar 2nd, 2004 at 01:56 PM.

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Dec 2003
    Location
    Michigan
    Posts
    101
    oooook.....nevermind i fixed it.
    had to set cancel = true under vbNo.

    oh well

  3. #3
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236
    You have to make Cancel = True or = -1

    VB Code:
    1. Private Sub Form_Unload(Cancel As Integer)
    2. Dim m As Integer
    3.  
    4. m = MsgBox ("Are you sure you want to exit?", vbExclamation + vbYesNo, "Exit?")
    5.  
    6. Select Case m
    7.  
    8.     Case vbYes
    9.         Unload frmMain
    10.  
    11.     Case vbNo
    12.         Cancel = True
    13.  
    14. End Select
    15. 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