Microsoft Office Tutorials and References
In Depth Information
Understanding VBA Syntax
title bar of the message box (and replaces the placeholder text title in the
same chart).
x = MsgBox (“Are we having fun yet?”, vbYesNo, “Question”)
That variation displays the message shown in Figure 2-5 and stores the
user’s answer to the question in a variable named x. (We talk about
variables in the next chapter.)
Figure 2-5:
Result of
with three
You can combine two or more options for the Buttons argument by using
a plus sign (+). The preceding MsgBox statement uses the vbYesNo and
vbQuestion constants to specify that the box show a question-mark icon as
well as the Yes/No buttons:
x = MsgBox (“Are we having fun yet?”, vbYesNo + vbQuestion, “Question”)
When executed, the preceding statement shows the box in Figure 2-6. Unlike
the one in the preceding example, this new box shows a question-mark icon
because of the + vbQuestion added to the second argument.
Figure 2-6:
with a
questionmark icon.
Chapter 2
Although you have some flexibility in how you express values for arguments,
you have almost no flexibility in terms of the order in which you place the
arguments within a statement. If you want to use just the first and third
arguments in a syntax chart, such as the Prompt and Title arguments of the
MsgBox function, you still need to include a comma for the second argument
to make clear that the last argument is the title, as in the following example:
x = MsgBox(“Howdy”, , “I am the Title”)
Search JabSto ::

Custom Search