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


Download 1.37 Mb.
Pdf ko'rish
bet143/191
Sana08.05.2023
Hajmi1.37 Mb.
#1442581
1   ...   139   140   141   142   143   144   145   146   ...   191
Bog'liq
2.2. Powerful PowerPoint For Educators

Next i
End Sub
Sub RightAnswerButton(answerButton As Shape)
Dim thisQuestionNum As Long
thisQuestionNum = _
ActivePresentation.SlideShowWindow.View.Slide.SlideIndex - 1
an 
swer(thisQuestionNum) = answerButton.TextFrame.TextRange.Text
RightAnswer
End Sub
Which Button Did I Press? 139


Sub WrongAnswerButton(answerButton As Shape)
Dim thisQuestionNum As Long
thisQuestionNum = _
ActivePresentation.SlideShowWindow.View.Slide.SlideIndex - 1
an 
swer(thisQuestionNum) = answerButton.TextFrame.TextRange.Text
WrongAnswer
End Sub
You have al ready seen (in the
RightAnswer
and 
WrongAnswer
pro ce dures)
thisQuestionNum
used to store the number of the current question. The only
new code is the 
Dim
state 
ment to de 
clare
an 
swer
as an ar 
ray and the
answerButton.TextFrame.TextRange.Text
to get the text from the but -
ton that was pressed (as described above). In ad dition, we have done a bit of re -
structuring. In the orig inal example in Chapter 7, each but ton had its own
procedure, and that procedure took care of storing the answer, keeping track of
which ques tion was an swered, and keep ing score. We have di vided up that
work. Now the
RightAnswerButton
and 
WrongAnswerButton
pro ce dures
take care of storing the answer, and the
RightAnswer
and 
WrongAnswer
pro -
cedures take care of keeping track of which question was answered and keeping
score.
This division of labor will be important when we add a short-answer ques-
tion. For short-answer questions, we are go ing to need a 

Download 1.37 Mb.

Do'stlaringiz bilan baham:
1   ...   139   140   141   142   143   144   145   146   ...   191




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