CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: msgBox

  1. #1
    Join Date
    May 1999
    Posts
    22

    msgBox

    I use a msgBox vbYesNo before i close the form.
    What can i do to do the difference between if the user press yes or no?



  2. #2
    Join Date
    Feb 2000
    Location
    Ireland
    Posts
    808

    Re: msgBox


    If MsgBox("Ask A Question", vbYesNo + vbQuestion) = vbYes then
    'Code for Yes
    else
    'Code for No
    End If





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

    Re: msgBox

    use the following

    Dim Reply as string

    Reply = msgbox("Are you sure?", vbyesno)

    If Reply = vbyes then

    End 'exit program

    End If

    Hope this helps

    Rob


  4. #4
    Join Date
    Jun 2000
    Location
    Germany
    Posts
    21

    Re: msgBox

    You have to use a variable dedicated to the msgBox if you want to react.You should use the values.6 is standard for "Yes" and 7 is standard for "no".With this piece of code your programm should work (pleas put it in one line):
    If msgBox("[enter your message here]", vb_yesno, "[Title]") = 6 then ... [if he chose "yes"] else ... [if he chose "no"]

    for example:
    If msgBox("Do you want to quit?", vb_yesno, "Quit?") = 6 then unload me

    In this case the programm ends if he chooses "yes"
    If he choses "no", nothing will happen!

    I hope this helps you! Bye, Nanobert


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