Most of the time when you show a message box, you know what the most likely answer will be. For example, if you ask "Do you want to save changes to Document 1?", most of the time, the answer will be Yes. If you aren't sure, choose the option which means that the user doesn't lose any work. For example, if he/she closed an application and accidentally pressed return when a message box displayed asking him/her to save changes, and its default answer was No, he would lose all his work.
To specify a default button simply add a vbDefaultButton1, or vbDefaultButton2 etc in the flags parameter. For example
Msgbox "Do you want to save changes?", vbYesNo+vbExclamation+vbDefaultButton1
, "Front Page"
would set the default button as Yes
Msgbox "Do you want to save changes?", vbYesNoCancel+vbExclamation+vbDefaultButton3
, "Front Page"
would set the default button as No.
Comments