Results 1 to 5 of 5

Thread: [RESOLVED] I received help on a VB 6.0? but I'm still confused please explain.

  1. #1

    Thread Starter
    Junior Member GreeDee's Avatar
    Join Date
    Sep 2005
    Posts
    20

    Resolved [RESOLVED] I received help on a VB 6.0? but I'm still confused please explain.

    So on this thread
    http://www.vbforums.com/showthread.php?t=364968
    Two fine posters showed me how to do a (Are You Sure Y/N?) box. Out of curiousity the one that was to be posted in my cmdExit bar has to be clicked on "Yes" twice in order for it to exit. Is that normal or have I done something wrong? Here is the code I was given.

    VB Code:
    1. Private Sub cmdExit_Click()
    2. If MsgBox("Are you sure you want to quit?", vbExclamation + vbYesNo) = vbNo Then
    3.   Exit Sub
    4.   End If
    5.   Unload Me
    6. End Sub

    The Unload Me comment, I've tried to name my form, but that just causes errors, whereas the unload me works, only "yes" has to be clicked twice.

    Again many thanks from the gurus in advance.

  2. #2
    Addicted Member Paradox's Avatar
    Join Date
    Sep 2004
    Location
    Nairobi
    Posts
    189

    Re: I received help on a VB 6.0? but I'm still confused please explain.

    Did you include the same code under
    VB Code:
    1. Private Sub Form_Unload(Cancel As Integer)
    2. End sub


    if you did thats why its being fired twice and the messagebox appears twice
    Peny wise pound Foolish

  3. #3
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: I received help on a VB 6.0? but I'm still confused please explain.

    Just use the ff...
    VB Code:
    1. Private Sub cmdExit_Click()
    2.   Unload Me
    3. End Sub
    4.  
    5. Private Sub Form_Unload(Cancel As Integer)
    6.     If MsgBox("Are you sure you want to exit?   ", vbQuestion + vbYesNo, "Confirm Exit") = vbNo Then
    7.         Cancel = 1
    8.     End If
    9. End Sub
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  4. #4

    Thread Starter
    Junior Member GreeDee's Avatar
    Join Date
    Sep 2005
    Posts
    20

    Re: I received help on a VB 6.0? but I'm still confused please explain.

    I can't believe that I didn't pick up on that. I am even having a hard time picking up the simple procedures.

    Thank you for pointing out the redundancy in my programming. I'll mark this topic resolved.

  5. #5
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: [RESOLVED] I received help on a VB 6.0? but I'm still confused please explain.

    Don't worry, you are not alone...
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

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