Microsoft Office Tutorials and References
In Depth Information
Constant
Value
Description
vbYesNo
4
Display Yes and No buttons
vbRetryCancel
5
Display Retry and Cancel buttons
vbCritical
16
Display Critical Message icon
vbQuestion
32
Display Warning Query icon
vbExclamation
48
Display Warning Message icon
vbInformation
64
Display Information Message icon
vbDefaultButton2
256
Second button is default
vbDefaultButton3
512
Third button is default
As mentioned, the function’s return value indicates which of the buttons the user selected. The
possible return values are represented by the constants shown in Table 23.5.
TABLE 23.5
Defined Constants for the MsgBox Function’s Return Value
Constant
Value
Button Selected
vbOK
1
OK
vbCancel
2
Cancel
vbAbort
3
Abort
vbRetry
4
Retry
vbIgnore
5
Ignore
vbYes
6
Yes
vbNo
7
No
To use the MsgBox function, call it with the appropriate arguments and then test the return value.
Here’s an example, with the displayed dialog box shown in Figure 23.2:
Dim retval As Integer
retval = MsgBox(“Delete file - are you sure?”, vbYesNo, _
“Confirm delete”)
If retval = vbYes Then
‘ Code to delete file goes here.
End If
Search JabSto ::




Custom Search