[Help]Message Box[Solved]
I was trying to make a notepad with a Advance save system, the code is:
MsgBox("Do you want to Save?", vbQuestion+vbYesNoCancel, "Do you want to Save?")
If MsgBoxResult.Yes then
*Private Coding*
End If
If MsgBoxResult.No Then
End
End If
If MsgBoxResult.Cancel Then
Stop
End If
It keeps skipping and going to the save if i hit "No" or "Cancel".
Whats wrong? Anything Missing?
If MsgBoxResult.Yes then
*Private Coding*
End If
'Nothing else so you dont need it
If MsgBoxResult.Cancel Then
Exit sub
'or e.cancel
End If
it still goes to the "Yes" Command.
Does anyone know?
Thanks Haddson.
Yes, the best way is to declare the result if you the possibility of more than two return types, otherwise you can use the following format:
[highlight=vbnet]If Msgbox("Do you want to retry ?", MsgBoxStyle.YesNo,"Msgbox Test")=MsgboxResult.vbYes Then
Msgbox("You pressed Yes")
Else
Msgbox("You pressed No")
End If[/highlight]
Can save some lines, but doesn't really matter.
Kinda does matter, But irrelevant,
in either case however, By declaring it first you leave yourself open for numerous options and many ways to use it, your way is static, used for yesno only, in this case we can use
Okonly,Yesno,YesNoCancel,Okcanel, You get the idea. Yours wouldn't even work with his scenario.