MsgBox (function)
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 |
Important: The message box has an approximate maximum allowed number of characters.
The:
|
||||
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 | OK | |||
ebCancel | 2 | Cancel | |||
ebAbort | 3 | Abort | |||
ebRetry | 4 | Retry | |||
ebIgnore | 5 | Ignore | |||
ebYes | 6 | Yes | |||
ebNo | 7 | No | |||
The type parameter is the sub of any of the following values: | |||||
Constant | Value | Displays | |||
ebOKOnly | 0 | OK button | |||
ebOKCancel | 1 | OK and Cancel buttons | |||
ebAbortRetryIgnore | 2 | Abort, Retry and Ignore buttons | |||
ebYesNoCancel | 3 | Displays Yes, No, and Cancel buttons. | |||
ebYesNo | 4 | Yes and No buttons. | |||
ebRetryCancel | 5 | Retry and Cancel 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:
The carriage-return or line-feed characters can be used by themselves to designate an end-of-line.
|
|||||
![]()
![]()
![]() |
|||||
Example |
|
||||
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.
|