[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]
: [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... : : : : :
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
[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
: 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]
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
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
Comments
[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...
: [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.
------------------------------------------------------------------------
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
: 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
[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]
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
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.