|
|
| Back to Excel Homepage | Excel VBA - Reference Guide |
|
Menu Message Box
Other links
|
A Message Box (MsgBox) displays a message alert box with optional set of buttons, icon and other arguments settings . There are two types of message boxes: 1. MsgBox Statement - One way communication to the user.
MsgBox prompt,[buttons],[title],[helpfile],[context]
2. MsgBox Function - Two way communication which the system returns a value.
Variable = MsgBox(prompt,[buttons],[title],[helpfile],[context])
Example1 - MsgBox Statement:
Example2 - MsgBox Function:
In the above example, the vbYesNo is the command used to create the Yes and No buttons and the + vbQuestion is the command to create the Question Mark image.
§ If the user clicks on Yes, the message box will return the constant vbYes. § If the user clicks on No, the message box will returns the constant vbNo.
Example2 - MsgBox Function (Multiple Lines):
The above example will display multiple lines in the message box using the constant vbNewLine.
Constants for MsgBoxButtons and icons are combined for the Buttons argument which have a unique value that drives the output of how users use and see button combinations:
The following applies to the MsgBox Function when the user clicks a button returning a unique value.
While a the MsgBox is being displayed, the macro procedure is paused waiting for the user to click a button whether it is a statement or a function.
Note the difference between the two types regarding when parenthesis are used and can be ignored. Also, be aware any function must be placed to the right side of an = (equal sign) because it returns an answer.
|
VBA Keyword: MsgBox |
|
© copyright 2010 TP Development & Consultancy Ltd, All Rights Reserved. All trademarks are copyrighted by their respective owners. Please read our terms of use and privacy policy. |