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


While 8 > 7 MsgBox ("Eight is still greater than seven.")


Download 1.37 Mb.
Pdf ko'rish
bet123/191
Sana08.05.2023
Hajmi1.37 Mb.
#1442581
1   ...   119   120   121   122   123   124   125   126   ...   191
Bog'liq
2.2. Powerful PowerPoint For Educators

While 8 > 7
MsgBox ("Eight is still greater than seven.")
Wend
Be cause 
8 > 7
is al ways
True
(i.e., 8 is always greater than 7), this loop will
never stop. Usually, you won’t have something so ob vious. You will either type
something wrong (per haps
>
when you meant
<
), or you will have a complicated
expression with variables, and you won’t realize that the con dition for stopping
never can be met.
If you get stuck in an in finite loop, it will ap pear that PowerPoint has
frozen. In all likelihood, you will have to force PowerPoint to quit. On a Win -
dows computer, you can use Ctrl-Alt-Delete (i.e., hold down the Ctrl and Alt
keys while hitting the De lete key). Depending on the version of Windows you
are run ning, you will ei ther restart your computer or be given the op tion to stop
an un 
responsive ap 
plication (PowerPoint, in this case). If you are on a
Macintosh, you will have to hit Command-Option-Esc (i.e., hold down the Com-
mand and Op tion keys while hit ting the Esc key; note that the Command key is
the one with the picture of the apple on it). If you do this, you will lose any
changes you made to your presentation since you saved it last. That is why it is
very important to save changes of ten, particularly when you are working with
loops. In fact, when testing out a loop, you should probably save your changes
before you put PowerPoint in Slide Show View.
Pa ram e ters
Sometimes a procedure has all the information it needs when you write it.
Sometimes it gets in formation from vari ables where we have stored in formation
(as long as the variables are de clared at the beginning of the mod ule). At other
times we want to give a pro cedure extra information as we go. We can do this
with something called a pa rameter. A parameter is extra information sent to a
procedure when it is called. We have used pa rameters when call ing procedures
(something as simple as a 
MsgBox
takes a parameter: the text to display), but we
have not used pa rameters in procedures we have written. Parameters are a very
useful tool for pro grammers, but they can be a bit tricky. Fol lowing is a brief ex -
planation of parameters, so when you see them in ex amples (such as the timed
functions in the next section), you’ll understand them.
Imagine that you wanted to put up a 
MsgBox
with different mes sages for
different occasions. Perhaps the message is the same ex cept for one thing. For
124 More Tricks for Your Scripting Bag


example, you might want to say, “You are do ing well, Ella” at some point and
“You are do ing poorly, Ella” at another time. We have done this with two sep a-
rate pro cedures in the past, but we could write one pro cedure with a parameter:

Download 1.37 Mb.

Do'stlaringiz bilan baham:
1   ...   119   120   121   122   123   124   125   126   ...   191




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