vbYesNo - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

vbYesNo

TroySTroyS Posts: 14Member
How would I specify in an if statement "if vbYes" (from a msgbox) - the syntax I'm using won't work. Like... if vbYes = 1 or = True or ...??? Thanks!

Comments

  • FatalsniperFatalsniper Posts: 55Member
    [b][red]This message was edited by Fatalsniper at 2002-11-3 0:5:49[/red][/b][hr]
    [b][red]This message was edited by Fatalsniper at 2002-11-3 0:4:50[/red][/b][hr]
    [b][red]This message was edited by Fatalsniper at 2002-11-3 0:3:28[/red][/b][hr]
    : How would I specify in an if statement "if vbYes" (from a msgbox) - the syntax I'm using won't work. Like... if vbYes = 1 or = True or ...??? Thanks!
    :
    I'm not sure but it could be something like this:

    [code]
    if (msgbox ("Your message",VBinformation,"Message") = VBYES)
    Exit sub 'Example to do something if it is true
    end if
    [/code]

    I'm not sure if that is...
    I hope it works...




  • MalcolmMalcolm Posts: 828Member
    : [b][red]This message was edited by Fatalsniper at 2002-11-3 0:5:49[/red][/b][hr]
    : [b][red]This message was edited by Fatalsniper at 2002-11-3 0:4:50[/red][/b][hr]
    : [b][red]This message was edited by Fatalsniper at 2002-11-3 0:3:28[/red][/b][hr]
    : : How would I specify in an if statement "if vbYes" (from a msgbox) - the syntax I'm using won't work. Like... if vbYes = 1 or = True or ...??? Thanks!
    : :
    : I'm not sure but it could be something like this:
    :
    : [code]
    : if (msgbox ("Your message",VBinformation,"Message") = VBYES)
    : Exit sub 'Example to do something if it is true
    : end if
    : [/code]
    :
    : I'm not sure if that is...
    : I hope it works...
    :
    :
    :
    :
    :

    That is it.

  • MihailVDMihailVD Posts: 91Member
    Here is the code:
    ------------------------------------------------------------------------
    Dim Answer As Long

    Private Sub Form_Activate()
    Answer = MsgBox("Is that it?", vbQuestion + vbYesNo, "Program")
    If Answer = vbYes Then MsgBox "User clicked YES"
    If Answer = vbNo then MsgBox "User clicked NO"
    End Sub
    ------------------------------------------------------------------------
    ---------------
    Mihail Dimitrov
    ICQ : 110064098

  • mitrmitr Posts: 3Member
    [b][red]This message was edited by mitr at 2002-11-3 12:24:54[/red][/b][hr]
    : How would I specify in an if statement "if vbYes" (from a msgbox) - the syntax I'm using won't work. Like... if vbYes = 1 or = True or ...??? Thanks!
    :
    whenever we use vbyesno it returns a long value
    therefore, your code must have a long variable
    vbyesno returns 6 for yes & 7 for no


    the will look like that :
    dim response as long
    response= msgbox("hello",vbyesno,"message")
    if (response=6) then
    msgbox"yes"
    else
    msgbox"no"
    endif

    that's it
    mitr


  • infidelinfidel Posts: 2,900Member
    : How would I specify in an if statement "if vbYes" (from a msgbox) - the syntax I'm using won't work. Like... if vbYes = 1 or = True or ...??? Thanks!

    [code]
    Dim answer As VbMsgBoxResult

    answer = MsgBox("Do you want to quit?", vbYesNoCancel, "End Program?")

    Select Case answer
    Case vbYes
    'do something
    Case vbNo
    'do something
    Case vbCancel
    'do something
    End Select
    [/code]
  • hackuhacku Posts: 1Member
    friends try this code its working for me

    for VBYesNoCancel

    copy this code and paste in your command button

    Private Sub cmdExit_Click()
    Dim hack As VbMsgBoxResult
    hack = MsgBox("Do you Want to Save Changes??", vbYesNoCancel + vbExclamation)
    Select Case hack
    Case vbYes
    Adodc1.Recordset.Save
    MsgBox ("Saved Recent modifications!!")
    End
    Case vbNo
    End
    Case vbCancel
    Cancel = True
    End Select
    End Sub
  • chael0508chael0508 Posts: 7Member
    This post has been deleted.
  • chael0508chael0508 Posts: 7Member
    This post has been deleted.
  • chael0508chael0508 Posts: 7Member
    This is the full code for vbYesNo:

    Private Sub cmdExit_Click()
    Dim answer As Integer
    answer = MsgBox("Are You Sure You Want To Exit?", vbQuestion + vbYesNo, "Warning")
    If answer = vbYes Then
    Unload Me
    End If
    End Sub

    that's all.
Sign In or Register to comment.