VBScript MsgBox Function
Definition and Usage
The MsgBox function can display a message box, wait for the user to click a button, and then return the value indicating which button was clicked.
The MsgBox function can return the following values:
- 1 = vbOK - The OK button is clicked.
- 2 = vbCancel - The cancel button is clicked.
- 3 = vbAbort - The terminate button is clicked.
- 4 = vbRetry - The retry button is clicked.
- 5 = vbIgnore - The ignore button is clicked.
- 6 = vbYes - The yes button is clicked.
- 7 = vbNo - The no button is clicked.
Comment:When both the helpfile and context parameters are specified, the user can press the F1 key to view the help.
Tip:See the InputBox function.
Syntax
MsgBox(prompt[,buttons][,title][,helpfile,context])
Parameters | Description |
---|---|
prompt | Required. The string expression that is displayed in the dialog box as the message. The maximum length of prompt is approximately 1024 characters, depending on the width of the characters used. If there are multiple lines in prompt, the lines can be separated by carriage return (Chr(13)), line feed (Chr(10)), or a combination of both (Chr(13) & Chr(10)). |
buttons |
The value expression, which is the sum of the numerical values representing the number and type of buttons to be displayed, the icon style used, the identifier for the default button, and the style of the message box. If omitted, the default value for buttons is 0. The value of button:
The first group of values (0 - 5) is used to describe the type and number of buttons displayed in the dialog box; the second group of values (16, 32, 48, 64) is used to describe the style of the icons; the third group of values (0, 256, 512) determines the default button; and the fourth group of values (0, 4096) determines the style of the message box. When generating the buttons parameter value by adding these numbers, only one number can be taken from each group. |
title | A string expression that displays in the dialog box title bar. If title is omitted, the name of the application is displayed in the title bar. |
helpfile | A string expression that identifies the help file that provides context-related help for the dialog box. If helpfile is provided, context must also be provided. Not available on 16-bit system platforms. |
context | A numeric expression that identifies the context number assigned to a help topic by the author of the help file. If context is provided, helpfile must also be provided. Not available on 16-bit system platforms. |
Example
dim answer answer=MsgBox("Hello everyone!",65,"Example") document.write(answer)