Name
MsgBox Function
Syntax
MsgBox(prompt[,buttons][,title][,helpfile,context])
-
prompt Use: Required
Data Subtype: String
The text of the message to display in the message box dialog.
-
buttons Use: Optional
Data Subtype: Numeric
The sum of the
Button,Icon,DefaultButton, andModalityconstant values.-
title Use: Optional
Data Subtype: String
The title displayed in the titlebar of the message box dialog.
-
helpfile Use: Optional
Data Subtype: String
An expression specifying the name of the help file to provide help functionality for the dialog.
-
context Use: Optional
Data Subtype: Numeric
An expression specifying a context ID within
helpfile.
Return Value
A Variant of subtype Integer indicating the button clicked by the user.
Description
Displays a dialog box containing a message, buttons, and optional icon to the user. The action taken by the user is returned by the function as an integer value.
Rules at a Glance
promptcan contain approximately 1,000 characters, including carriage return characters such as the built-invbCrLfconstant.In order to divide
promptonto multiple lines, you can use any of thevbCr,vbLf,vbCrLf, orvbNewLineconstants. For example:SMsg = "This is line 1" & vbCrLf & _ "This is line 2"
If the
titleparameter is omitted, the text oftitledepends on the type of script being executed, as the following table shows:Script Type
Caption
ASP script
not applicable
IE script
“VBScript”
Outlook form
“VBScript”
WSH script
“VBScript”
If the
helpfileparameter is provided, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access