May 13, 2021 VBScript
The function of the MsgBox function is to pop up a dialog box waiting for the user to click the button and return an Integer value indicating which button the user clicked.
The MsgBox function displays a message box that waits for the user to click a button and then returns the value indicating the button being clicked.
The MsgBox function returns the following value:
Note: When both the helpfile and context parameters are specified, the user can press F1 to view the help.
Tip: See InputBox functions.
parameter | describe |
---|---|
prompt | Required.The string expression in the dialog box is displayed as a message.The maximum length of PROMPT is approximately 1024 characters, depending on the width of the characters used.If you contain multiple rows in the PROMPT, you can use a return between the rows (CHR (13)), a wrap (CHR (10)) or the carriage return (CHR (13) & chr (10)) Separate each line. |
buttons |
Optionally, it is the sum of the number of icon styles, default buttons, and numerical values of the message box style, using the icon style, the identity of the default button, and the value of the message frame style.The default is 0.
We can divide the button into four groups: the first set value (0-5) is used to describe the type and number of buttons displayed in the dialog; the second set value (16, 32, 48, 64) is used to describe the style of the icon;The third group value (0, 256, 512, 768) is used to determine the default button; and the fourth set value (0, 4096) determines the style of the message box.When these numbers generate the Buttons parameter value, only one number can be taken from each group value. |
title | Optional.The title of the message box.By default is the name of the application. |
helpfile | Optional.String expressions, used to identify the help file for context-related help.It must be used with the context parameter. |
context | Optional.Numerical expressions, used to identify the context number assigned to a help topic by the author of the help file.It must be used with the HelpFile parameters. |
Message box with line break:
Different buttonsets and different icons. Returns the value of the clicked button:
Message box with title: