Syntax |
MsgBox(msg [,[type] [,title]]) |
||||
Description |
Displays a message in a dialog box with a set of predefined buttons, returning an Integer representing which button was selected. |
||||
Comments |
The MsgBox function takes the following parameters: |
||||
|
Parameter |
Description |
|||
|
msg |
Message to be displayed—any expression convertible to a String. End-of-lines can be used to separate lines (either a carriage return, line feed, or both). If a given line is too long, it will be word-wrapped. If msg contains character 0, then only the characters up to the character 0 will be displayed. The width and height of the dialog box are sized to hold the entire contents of msg. A runtime error is generated if msg is Null. |
|||
|
type |
Integer specifying the type of dialog box (see below). |
|||
|
title
|
Caption of the dialog box. This parameter is any expression convertible to a String. If it is omitted, then the script is used. A runtime error is generated if title is Null. |
|||
|
|
The MsgBox function returns one of the following values: |
|||
|
Constant |
Value |
The following is clicked |
||
|
ebOK |
1 |
|
||
|
ebCancel |
2 |
|
||
|
ebAbort |
3 |
|
||
|
ebRetry |
4 |
|
||
|
ebIgnore |
5 |
|
||
|
ebYes |
6 |
|
||
|
ebNo |
7 |
|
||
|
The typeparameter is the sub of any of the following values: |
||||
|
Constant |
Value |
Displays |
||
|
ebOKOnly |
0 |
button |
||
|
ebOKCancel |
1 |
and buttons |
||
|
ebAbortRetryIgnore |
2 |
, and buttons |
||
|
ebYesNoCancel |
3 |
Displays , , and buttons. |
||
|
ebYesNo |
4 |
and buttons. |
||
|
ebRetryCancel |
5 |
and buttons |
||
|
ebCritical |
16 |
Stop icon |
|
|
|
ebQuestion |
32 |
Question Mark icon |
|
|
|
ebExclamation |
48 |
Exclamation Point icon |
|
|
|
ebInformation |
64 |
Information icon |
|
|
|
ebDefaultButton1 |
0 |
First button is the default button. |
||
|
ebDefaultButton2 |
256 |
Second button is the default button. |
||
|
ebDefaultButton3 |
512 |
Third button is the default button. |
||
|
ebApplicationModal |
0 |
Application modal; the current application is suspended until the dialog box is closed. |
||
|
The default value for type is 0 (display only the OK button, making it the default). Breaking Text across Lines The msg parameter can contain end-of-line characters, forcing the text that follows to start on a new line. The following example shows how to display a string on two lines: MsgBox "This is on" + Chr(13) + Chr(10) + "two lines." The carriage-return or line-feed characters can be used by themselves to designate an end-of-line. |
||||
|
r = MsgBox("Hello, World")
r = MsgBox("Hello, World",ebYesNoCancel Or ebDefaultButton1)
r = MsgBox("Hello, World",ebYesNoCancel Or ebDefaultButton1 Or ebCritical)
|
||||
Example |
Sub Main() |
||||
See Also |
AskBox$ (function); AskPassword$ (function); InputBox, InputBox$ (functions); OpenFilename$ (function); SaveFilename$ (function); SelectBox (function); AnswerBox (function). |
||||
Note |
MsgBox displays all text in its dialog box in 8-point MS Sans Serif. |
M |