Ques
tion
pro ce dure
for each question. That pro cedure will ask the ques tion, judge the answer, and
store the answer. When it fig ures out if the an swer was right or wrong, it will
call the
RightAnswer
or
WrongAnswer
pro cedure. So we need the fol low-
ing pro ce dures:
• Each short-answer question needs its own
Ques
tion
pro ce dure
(
Question1
,
Question2
,
Question3
).
• All the multiple-choice ques tions need one
RightAnswerButton
and one
WrongAnswerButton
pro cedure, which will be tied to ev -
ery but ton with a right and wrong an swer, respectively.
• All the questions need one
RightAnswer
and
WrongAnswer
procedure, which is called from
RightAnswerButton
,
WrongAnswerButton
, and each
Ques
tion
pro ce dure.
Next, our
Ques
tion
pro cedures need a slight mod ification so they can
store the answer in the
an
swer
ar
ray. Here is an example procedure for
Question3
:
Sub Question3()
Dim theAnswer As String
Dim thisQuestionNum As Long
thisQuestionNum = _
ActivePresentation.SlideShowWindow.View.Slide.SlideIndex - 1
140 More Tricks for Your Scripting Bag
theAnswer = InputBox(Prompt:="What is the cap
ital of Mary
land?", _
Ti
tle:="Question " & thisQuestionNum)
If qAnswered(thisQuestionNum) = False Then
an
swer(thisQuestionNum) = theAnswer
Do'stlaringiz bilan baham: |