prompt: A string of up to approximately 1024 characters. It's possible to insert line breaks with chr(10) and/or chr(13).
If the value of title is not specified, it defaults to the application name of the program from where the message box is displayed, for example Microsoft Excel.
Value of buttons
The value of the buttons parameter specifies which buttons and icons are shown, which button is the default button and some miscellaneous stuff such as the modality of the message box.
The default value of buttons is 0.
Shown buttons
vbOKOnly
OK button
0
vbOKCancel
OK and Cancel
1
vbAbortRetryIgnore
Abort, Retry and Ignore
2
vbYesNoCancel
Yes, No and Cancel
3
vbYesNo
Yes and No
4
vbRetryCancel
Retry and Cancel
5
Adding vbMsgBoxHelpButton (16384) to the value adds an attional help button to the message box.
Shown icons
vbCritical
Critical Message
16
vbQuestion
Warning Query
32
vbExclamation
Warning Message
48
vbInformation
Information Message
64
Default button
vbDefaultButton1
First button
0
vbDefaultButton2
Second button
256
vbDefaultButton3
Third button
512
vbDefaultButton4
Fourth button
768
Misc
vbApplicationModal
Application modal; the user must respond to the message box before continuing work in the current application.
0
vbSystemModal
System modal; all applications are suspended until the user responds to the message box.
4096
vbMsgBoxSetForeground
Specifies the message box window as the foreground window.
65536
vbMsgBoxRight
Text is right-aligned.
524288
vbMsgBoxRtlReading
Specifies text should appear as right-to-left reading on Hebrew and Arabic systems.
1048576
Return value
The return value indicates which button was clicked by the user:
vbOK
OK
1
vbCancel
Cancel
2
vbAbort
Abort
3
vbRetry
Retry
4
vbIgnore
Ignore
5
vbYes
Yes
6
vbNo
No
7
Create a message box with a title
msgBox "The number is 42", vbOK, "Hello world!"
Using a Yes/No message box in an IF statement
if msgBox("Do you really want to strawberries", vbYesNo + vbQuestion, "Confirmation of selection") = vbYes then
…
end if