The MsgBox function displays a message in a dialog box and waits for the user to click a button. The return value indicates which button the user has clicked.
|
Syntax | ||||
|
MsgBox(Text [, Buttons [, Title [, ParentWinHandle]]]) | ||||
|
Return value | ||||
|
Type |
Description | |||
|
MsgBoxReturn |
The code of the clicked button | |||
|
Parameter | ||||
|
Use |
Name |
Type |
Passing |
Description |
|
Required |
Text |
String |
ByVal |
Message text |
|
Optional |
Buttons |
MsgBoxStyle |
ByVal |
Attributes of the message. |
|
Optional |
Title |
String |
ByVal |
Text displayed in the title of the window. |
|
Optional |
ParentWinHandle |
Long |
ByVal |
Handle of the parent window |
|
MsgBoxReturn |
Description |
|
3 – Abort |
The button Abort has been pressed |
|
2 – Cancel |
The button Cancel has been pressed |
|
5 – Ignore |
The button Ignore has been pressed |
|
7 – No |
The button No has been pressed |
|
1 – OK |
The button OK has been pressed |
|
4 – Retry |
The button Retry has been pressed |
|
6 – Yes |
The button Yes has been pressed |
|
MsgBoxStyle |
Description |
|
2 – AbortRetryIgnore |
Display of the buttons Cancel, Retry, and Ignore |
|
0 – ApplicationModal |
The message box is bound to the application |
|
16 – Critical |
Display of the Stop symbol |
|
0 – DefaultButton1 |
The first button is the standard button |
|
256 – DefaultButton2 |
The second button is the standard button |
|
512 – DefaultButton3 |
The third button is the standard button |
|
768 – DefaultButton4 |
The fourth button is the standard button |
|
48 – Exclamation |
Display of the Exclamation symbol |
|
16384 – HelpButton |
Display of a Help Button (without functionality) |
|
64 – Information |
Display of the Info symbol |
|
524288 – MsgBoxRight |
The buttons will be aligned left |
|
1 – OKCancel |
Display of the buttons OK and Cancel |
|
0 – OKOnly |
Display of the button OK |
|
32 – Question |
Display of the Question symbol |
|
5 – RetryCancel |
Display of the buttons Retry and Cancel |
|
1048576 – RtlReading |
The text will be displayed for Right-To-Left reading |
|
65536 – SetForeground |
Sets the message to foreground |
|
4096 – SystemModal |
The dialog is bound to the system. All applications are blocked until the user is closing the message. |
|
8192 – TaskModal |
The message box is bound to the task. |
|
4 – YesNo |
Display of the buttons Yes and No |
|
3 – YesNoCancel |
Display of the buttons Yes, No, and Cancel |
Note:
ParentWinHandle is used to bind the message box to a parent window. If ParentWinHandle is not specified, the message box is displayed on the primary monitor, or on the monitor where the upper-left corner of the parent window is located.