Powerful PowerPoint for Educators: Using Visual Basic for Applications to Make PowerPoint Interactive


whichButton will store in formation about which but ton was pressed, and the sec ond pa rameter to MsgBox


Download 1.37 Mb.
Pdf ko'rish
bet61/191
Sana08.05.2023
Hajmi1.37 Mb.
#1442581
1   ...   57   58   59   60   61   62   63   64   ...   191
Bog'liq
2.2. Powerful PowerPoint For Educators

whichButton
will store in formation about which but ton was
pressed, and the sec ond pa rameter to
MsgBox
(af ter the mes sage that is to ap pear
66 A Scripting Bag of Tricks


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, 

Download 1.37 Mb.

Do'stlaringiz bilan baham:
1   ...   57   58   59   60   61   62   63   64   ...   191




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling