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


Wait pro ce dure. Then add the fol low ing pro ce dure: Sub HelloWaitGoodbye()


Download 1.37 Mb.
Pdf ko'rish
bet126/191
Sana08.05.2023
Hajmi1.37 Mb.
#1442581
1   ...   122   123   124   125   126   127   128   129   ...   191
Bog'liq
2.2. Powerful PowerPoint For Educators

Wait
pro ce dure. Then add the fol low ing pro ce dure:
Sub HelloWaitGoodbye()
MsgBox ("Hello")
Wait
MsgBox ("Good 
bye")
End Sub
When you run 
HelloWaitGoodbye
, you should see a
MsgBox
that says
“Hello.” Af ter you click OK to dis miss the 
MsgBox
, you should see a
MsgBox
that says “Goodbye,” but only after a de lay of five seconds.
Now suppose that you want to wait, but not always for five seconds. You
could write sev eral dif fer ent pro ce dures (
Wait5
,
Wait10
,
Wait60
, etc.) to wait
different amounts of time, but we can use a sim ple parameter to write one proce-
dure that can wait dif ferent amounts of time.
126 More Tricks for Your Scripting Bag


Sub Wait(waitTime As Long)
start = Timer
While Timer < start + waitTime
DoEvents
Wend
End Sub
In this pro cedure, instead of setting the
waitTime
to five, we call
Wait
with
however long we want to wait (e.g.,
Wait (60)
would wait sixty seconds).
Timed func tions are useful if you want to give your users a chance to do
something be fore moving on. For example, you might display a text box, wait a
short time, then display a second text box. This allows the user to focus on the
first text box be fore getting too much in formation. Be careful with timed func-
tions, be cause dif ferent people read at dif ferent speeds. If you set your wait times
too long, some people will get restless waiting for the next thing to hap pen. If
you set them too short, some peo ple will not have time to finish the first thing.
Some tim ing can be done automatically without VBA. You can use Custom
Animation to have things ap pear and disappear as much as you like. How ever, as
with many things that you can do without VBA, you might find that you can do
more with VBA. For ex ample, you might ask the user how fast to go:

Download 1.37 Mb.

Do'stlaringiz bilan baham:
1   ...   122   123   124   125   126   127   128   129   ...   191




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