| You should always assign a MsgBox()
function to an integer variable ,this
is used to store the return value.
Message boxes can display multiple
buttons, such as Yes, No, and Cancel. The
return value will indicate which button
the user clicked. Here is an example
intReply = MsgBox ("Do you want
to quit" , vbQuestion + vbYesNoCancel
,"Log-off" )
The syntax of the MsgBox () function
is this variable
= MsgBox( strMsg [, [intType]
[, strTitle] ] )
The only required argument here is
strMsg this is the message
that is displayed in the actual message
box (remember the string or variable
to displayed must be surrounded by
quotation marks), strTitle
is an optional string that represents
the text in the message box's title
bar , if this is not entered the project
name is entered into the title bar
instead. intType is
an optional numeric value or expression
that describes the options you want
in the message box . Using intType
you can specify what icons or button
combinations will be displayed in
the message box.
Here is a table of the button combinations
| Named
Literal |
Value |
Description |
| vbOKOnly |
0 |
Displays the OK
button |
| VbOKCancel |
1 |
Displays the OK
and Cancel buttons |
| vbAbortRetryIgnore |
2 |
Displays Abort,
Retry, and Ignore buttons |
| VbYesNoCancel |
3 |
Displays the Yes,
No, and Cancel buttons |
| VbYesNo |
4 |
Displays the Yes
and No buttons |
| VbRetryCancel |
5 |
Displays the Retry
and Cancel buttons |
Here is a table with the
icons that can be displayed.
| Named
Literal |
Value |
Icon
Image |
| vbCritical |
16 |
 |
| vbQuestion |
32 |
 |
| vbExclamation |
48 |
 |
| vbInformation |
64 |
 |
| VbSystemModal |
4096 |
Displays a SystemModal
dialog box. |
You can also name the default button
to be used , here is a table with
all the values
| Named
Literal |
Value |
Description |
| vbDefaultButton1 |
0 |
The first button
is the default. |
| vbDefaultButton2 |
256 |
The second button
is the default. |
| vbDefaultButton3 |
512 |
The third button
is the default. |
|