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


MsgBox and ends with an ex ample that moves to a particular slide based on which but ton is pressed in the MsgBox


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

MsgBox
and ends with an ex ample that
moves to a particular slide based on which but ton is pressed in the
MsgBox
.
The Secrets of the MsgBox
Until now, we have used the 
MsgBox
com mand to pop messages up on the
screen. That is its main pur pose. How ever, it can do more. Although it can’t let
the user type a mes sage (use
InputBox
for that), 
MsgBox
can display a few dif-
ferent combinations of but tons. If you don’t tell it which but tons to use, it just
has an OK but ton. The fol lowing ta ble shows the dif ferent but ton combinations
you can use along with the se cret word, which we’ll call a “constant,” to ac cess
that com bination. I’ll ex plain the secret word after the table.
But ton(s)
Con stant
OK
vbOK
OK, Cancel
vbOKCancel
Abort, Retry, Ig nore
vbAbortRetryIgnore
Yes, No, Can cel
vbYesNoCancel
Yes, No
vbYesNo
Re try, Can cel
vbRetryCancel
We can now use a 
MsgBox
to ask a simple question. We don’t have a lot of
choices for the an swers (just the limited choices above), but at least we can ask a
yes/no ques tion with a 
MsgBox
. For anything more complicated, just use ac tion
buttons on a slide and skip the 
MsgBox
.
To put more but tons in a
MsgBox
, we need to do two things: add a second
ar gu ment to the
MsgBox
com mand (that’s where the se cret word co mes in) and
store the an swer in a variable. Because the user can press one of two or three but-
tons, we need a way to keep track of which but ton was pressed. For example:
whichButton = MsgBox("Do you like choc 
olate?", vbYesNo)
The variable

Download 1.37 Mb.

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




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