CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2001
    Posts
    13

    Question on MsgBox

    Hello all. I am rather new at this. I have a code written that asks the user if they want to import the data they are working with, and it does so with a MsgBox code with the vbYesNo command, so they can click YES or NO. How do I use the returned value on this to either quit the function, or go to the next part when it will import the data? Here is an example of what I have, can someone help me?

    MsgBox "Do you want to import the data?", vbYesNo
    If VbYesNo = 2 then Exit Function


    I assume that since the other possible value is the 1 for YES, that it will automatically progress to the lines of code directly below it. Help!

    Thanks,

    Bill Garrett




  2. #2
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: Question on MsgBox


    if MsgBox ("Do you want to import the data?", vbYesNo) = vbNo then
    Exit Function
    else
    ...
    Endif





  3. #3
    Join Date
    Jun 2001
    Location
    Memphis, TN
    Posts
    146

    Re: Question on MsgBox

    See if this helps out...


    retval = MsgBox("Yes or No", vbYesNo)
    If retval = vbYes then
    MsgBox "You hit yes"
    else
    MsgBox "You hit no"
    End If





  4. #4
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Question on MsgBox

    dim r
    r = MsgBox ("Do you want to import the data?", vbYesNo)
    if r = vbNo then Exit Sub



    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

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