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


Download 1.37 Mb.
Pdf ko'rish
bet52/191
Sana08.05.2023
Hajmi1.37 Mb.
#1442581
1   ...   48   49   50   51   52   53   54   55   ...   191
Bog'liq
2.2. Powerful PowerPoint For Educators

ElseIf
to the 
YourName
pro ce dure.
Sub YourName()
Dim done As Boolean
done = False
While Not done
userName = InputBox(prompt:="Type your name", _
Ti 
tle:="Input Name")
If userName = "" Then
done = False
ElseIf userName = "Em 
ily" Then
MsgBox("Fin 
ish your home 
work be 
fore do 
ing this.")
done = False
Else
done = True
End If
Wend
End Sub
What Else? A Personal Re sponse and a Short-Answer Question 57


After we ask the question about the student typ ing noth ing, we ask one
more ques tion. So first, we check to see if 
userName
is noth ing. If it is n’t, we
ask if 
userName
is “Em ily.” If 
userName
isn’t noth ing, and it is n’t Em ily, then
we look at what co mes af ter
Else
. If 
userName
is “Emily,” we have two things
to do: put up a message telling Em ily to do her homework, and set
done
to
False
. Be cause
done
is 
False
(just like it would be if the stu dent typed noth -
ing), we’ll ask for the name again.
This could be expanded to ask as many ques tions as you want by add ing
more
ElseIf
questions. Each one could check for a different name (or an un ac-
cept able an swer, like pro fan ity) and re spond ap pro pri ately. Note that
ElseIf
does not have a space between “Else” and “If” while
End If 
does have a space
between “End” and “If.”
Using the exact same structure, we can change this from ask ing for a stu -
dent’s name to asking for the an swer to a question. The main structure of the
VBA looks like this:

Download 1.37 Mb.

Do'stlaringiz bilan baham:
1   ...   48   49   50   51   52   53   54   55   ...   191




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