and the comma) is the constant that tells
MsgBox
which but tons to use. Fig ure
6.1
shows the
MsgBox
.
Fig ure 6.1. MsgBox with Yes and No Buttons
The se cret words are called constants because they represent constant val-
ues (unlike
variables, which can change value). In this case, the constants are
mne mon ics for num bers. For ex am ple,
vbYesNo
is really the num ber 4. Wher-
ever you
see the constant
vbYesNo
, you could type 4 in stead. However, it might
be eas ier to re member that
vbYesNo
means “I want Yes and No buttons” than
remembering what 4
means in a
MsgBox
com mand. You can make your own
constants, but we’ll just use the ones that come with VBA;
these usu ally start
with the let ters
vb
(for Vi sual Ba sic) or
mso
(for Microsoft Of fice), so if you
ever see
something that starts with
vb
or
mso
, it is prob ably a constant.
VBA co mes with hun dreds of con stants that can be used with different
commands, and it co mes with a few more for the
MsgBox
com mand. The most
important
ones are values returned by
MsgBox
de pending on which but ton was
pressed. The following are the possible values:
vbOK
,
vbCancel
,
vbAbort
,
vbRetry
,
vbIgnore
,
vbYes
, and
vbNo
. For ex ample,
if the user clicks the Yes
but ton,
Do'stlaringiz bilan baham: