Microsoft Office Tutorials and References
In Depth Information
Figure 7-1. A MsgBox dialog box
Modality
vbApplicationModal
0
Application modal message box
vbSystemModal
4096
System modal message box
For instance, the code:
MsgBox "Proceed?", vbQuestion + vbYesNo
displays the message box shown in Figure 7-1 which includes a question mark icon and two ,
command buttons, labeled Yes and No.
Figure 7-1. A MsgBox dialog box
The title parameter is a string expression that is displayed in the title bar of the dialog box. If
we omit this argument, then "Microsoft Excel" will be displayed, as in Figure 7-1 .
The MsgBox function returns a number indicating which button was selected. These return values
are given in Table 7-3 . (They are officially defined in the VbMsgBoxResult enum.)
Table 7-3. MsgBox Return Values
Constant
Value
Description
vbOK
1
OK button pressed
vbCancel
2
Cancel button pressed
vbAbort
3
Abort button pressed
vbRetry
4
Retry button pressed
vbIgnore
5
Ignore button pressed
vbYes
6
Yes button pressed
vbNo
7
No button pressed
7.2 The InputBox Function
The InputBox function is designed to get input from the user. The most commonly used (but not
the complete) syntax is:
InputBox( prompt [, title ] [, default ])
where prompt is the message in the input box, title is the title for the input box, and default
is the default value that is displayed in the text box. For instance, the code:
sName = InputBox("Enter your name.", "Name", "Albert")
produces the dialog box in Figure 7-2 .
 
 
 
 
 
Search JabSto ::




Custom Search