Microsoft Office Tutorials and References
In Depth Information
7.1 The MsgBox Function
DatePart
InstrRev*
PPmt
UCase
DateSerial
Int
PV
Val
DateValue
Ipmt
QBColor
VarType
Day
IRR
Rate
WeekdayWeekdayName*
DDB
IsArray
Replace*
Year
Dir
IsDate
RGB
[1] Items marked with an asterisk (*) are for Office 9/10 only.
7.1 The MsgBox Function
We have been using the MsgBox function unofficially for some time now. Let us introduce it
officially. The MsgBox function is used to display a message and wait for the user to respond by
pushing a button. The most commonly used syntax is:
MsgBox( prompt [, buttons ] [, title ])
This is not the function's complete syntax. There are some additional optional parameters related
to help contexts that you can look up in the help documentation.
prompt is a String parameter containing the message to be displayed in the dialog box. Note that
a multiline message can be created by interspersing the vbCrLf constant within the message.
buttons is a Long parameter giving the sum of values that specify various properties of the
message box. These properties are the number and type of buttons to display, the icon style to use,
the identity of the default button, and the modality of the message box. (A system modal dialog
box remains on top of all currently open windows and captures the input focus systemwide,
whereas an application modal dialog box remains on top of the application's windows only and
captures the application's focus.) The various values of Buttons that we can sum are shown in
Table 7-2 . (They are officially defined in the VbMsgBoxStyle enum.)
Table 7-2. The Ms gBox B uttons Argument Values
Purpose
Constant
Value
Description
Button types
vbOKOnly
0
Display OK button only
vbOKCancel
1
Display OK and Cancel buttons
vbAbortRetryIgnore
2
Display Abort, Retry, and Ignore buttons
vbYesNoCancel
3
Display Yes, No, and Cancel buttons
vbYesNo
4
Display Yes and No buttons
vbRetryCancel
5
Display Retry and Cancel buttons
Icon types
vbCritical
6 1
Display Critical Message icon
vbQuestion
32
Display Warning Query icon
vbExclamation
8 4
Display Warning Message icon
vbInformation
64
Display Information Message icon
Default button
vbDefaultButton1
0
First button is default
vbDefaultButton2
256
Second button is default
vbDefaultButton3
512
Third button is default
vbDefaultButton4
768
Fourth button is default
 
 
Search JabSto ::




Custom Search