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


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

Sub Ques 
tion()
Dim done As Boolean
done = False
While Not done
an 
swer = InputBox(prompt:="What color is the sky?", _
Ti 
tle:="Question")
If an 
swer = "" Then
done = False
ElseIf an 
swer = "blue" Then
MsgBox("Good job.")
done = True
Else
MsgBox("Try Again.")
done = False
End If
Wend
End Sub
You should notice that this is al most iden tical to 
YourName
, with the fol lowing
ex cep tions:
• We changed the name of the pro cedure; you can name pro cedures
anything you want as long as they make sense to you.
• We changed the name of the variable; you can name variables any-
thing you want as long as they make sense to you.
• We changed the text in the
InputBox
; as a scripter, you always
should look for text be tween quotes that you can change.
• We changed the text in the
ElseIf
line to check to compare what
was typed to the right an swer; remember, as a scripter, you should be 
looking to change the text for the question and the text for the an -
swer to whatever you want.
58 Let’s Get Scripting


• We changed the
done = False 
to
done = True 
af ter 
ElseIf
and
done = True 
to
done = False
af ter
Else
; this is be cause
you are done (
done = True
) when you get the right answer.
• Finally, we added some feedback. If what was typed wasn’t noth ing
and it wasn’t the right answer, we pop up a 
MsgBox
to tell the stu -
dent to try again.
Think about the small dif ferences be tween the

Download 1.37 Mb.

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




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