vba MsgBox Yes or No

Is there a way to do a MsgBox prompt for a "Yes" or "No" question

For example the MsgBox would ask "Do you want to save this file?"

and the user would respond with a yes or no  and the program would be able to get either the Yes or No response.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


pls use

Result = MsgBox("Do you want to save this file?", vbYesNo)

Open in new window

Result = 6 if Yes
Result = 7 if No

if you want to use cancel

Result = MsgBox("Do you want to save this file?", vbYesNoCancel)

Open in new window

Result = 6 if Yes
Result = 7 if No
Result = 2 if Cancel

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
[ fanpages ]IT Services ConsultantCommented:

Just to expand on what has already been provided:

If MsgBox("Do you want to save this file?", vbQuestion Or vbYesNo) = vbYes Then
' Whatever you need to do if [Yes] is selected
' ...or if [No] is selected
End If


tesla764Author Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.