The MsgBox statement can also be used like this:
Response = MsgBox("Here's My Message", 17, "Message Title")
which allows it to be used for not only displaying a message, but recording
the response as well. The 17 is the sum of a few different values, which specify
the options used to customize the message box. Figure 9-1 shows two
sample message boxes, each with different buttons and icons.
To choose the buttons that are displayed by the MsgBox function, specify:
0 for OK
1 for OK & Cancel
2 for Abort, Retry, & Ignore
3 for Yes, No, & Cancel
4 for Yes & No
5 for Retry & Cancel
To choose the icon that is displayed, specify:
16 for a red ?— (error)
32 for a question mark (query)
48 for an exclamation mark (warning)
64 for a blue ???I??? (information)
Additionally, you can add:
256 to give the second button the focus (dotted lines)
512 to give the third button the focus
4096 to make the message box ???system modal??? (i.e., all applications are
suspended until the user responds to the message box)
Figure 9-1. Various options can be combined to produce a variety of message boxes
518 | Chapter 9: Scripting and Automation
So, to have a message box with the Yes and No buttons, to have the question
mark icon, and to have No be the default, you would specify a value of
4 + 32 + 256 = 292. The two message boxes in Figure 9-1 have values of 17
(that??™s OK, Cancel, and the ?— icon) and 292, respectively. Note that it??™s
good practice not to add the values together (like I did in the first example
with 17), but rather to leave them separated, like this:
Response = MsgBox("Here's My Message", 16 + 1, "Message Title")
This way, it??™s easier to understand and modify later on.
Pages:
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720