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


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

Sub Do 
ing(doingHow As String)
MsgBox ("You are do 
ing " & doingHow & ", " & username)
End Sub
For something this simple, the pa rameter may not be worth the effort, but it can
be very use ful if the procedure that takes the pa rameter is more com plicated. In
this case 
doingHow
is the parameter. It is a 
String
be cause it is de clared in the
Sub
state ment to be a 
String
, so another procedure would call
doingHow
with
a
String
in pa ren the ses. For example
Do 
ing("well")
would pop up a
MsgBox
that says, “You are do ing well, Ella” (assuming the 
userName
was
“Ella”) . This might be called from a pro cedure that in cluded the following
If
block:
If numCorrect > 10 Then
Do 
ing ("su 
perbly")
ElseIf numCorrect > 8 Then
Do 
ing ("well")
ElseIf numCorrect > 5 Then
Do 
ing ("OK")
ElseIf numCorrect > 3 Then
Do 
ing ("Poorly")
Else
Do 
ing ("Very Poorly")
End If
Parameters can be of any type. We used a 
String
in this ex ample, but you can
pass var ious kinds of num bers or 
Boolean
s or even ob jects such as shapes. You
can pass more than one pa rameter as well if you need dif ferent kinds of in forma-
tion passed to a pro cedure, but for most of your pur poses, if you need a parame-
ter at all, one will suffice. Parameters can be tricky and com plicated, so we will
not use them a lot, but now you have a basic un derstanding of how they work in
case you see them in some examples.
Timed Functions
Most actions in PowerPoint happen be cause the user did something, such
as pressing a but ton to go to another slide. Sometimes, how ever, you want things 
to hap pen whether or not the user has done anything. For ex ample, you might
want a sound to start playing a few seconds after the slide is shown. You might
want the presentation to go from slide to slide on its own. You might want in for-
mation to pop up on the screen, then go away, and then have other in formation
pop up on the screen.
As soon as the user clicks on a but ton tied to a script with timing features
(such as the but ton to go to another slide), you can start any thing hap pening af ter
Timed Functions 125


any length of time. Of course, the standard “Custom Animation” choice from the 
Slide Show menu can al low ob jects to appear with timing, but you might want to 
do more. If you want something to happen after a short delay, you can use the
following procedure:

Download 1.37 Mb.

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




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