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


Download 1.37 Mb.
Pdf ko'rish
bet138/191
Sana08.05.2023
Hajmi1.37 Mb.
#1442581
1   ...   134   135   136   137   138   139   140   141   ...   191
Bog'liq
2.2. Powerful PowerPoint For Educators

Dim
state ments and
Ini 
tial 
ize
pro cedure from above and the
GetStarted
,
YourName
,
DoingWell
, and 
DoingPoorly
pro ce dures from
any of the earlier examples, we can use the following
RightAnswer
pro ce dure
and
WrongAnswer
procedure to re place all the specialized
RightAnswer
and
WrongAnswer
pro cedures. The only thing you ever have to change is the num-
ber
5
in the 
Dim
state ment and the
Ini 
tial 
ize
pro cedure. Just make this num-
ber equal to the num ber of questions you have.
Sub RightAnswer()
Dim thisQuestionNum As Long
thisQuestionNum = _
ActivePresentation.SlideShowWindow.View.Slide.SlideIndex - 1
If qAnswered(thisQuestionNum) = False Then
numCorrect = numCorrect + 1
End If
qAnswered(thisQuestionNum) = True
DoingWell
End Sub
Sub WrongAnswer()
Dim thisQuestionNum As Long
thisQuestionNum = _
ActivePresentation.SlideShowWindow.View.Slide.SlideIndex - 1
If qAnswered(thisQuestionNum) = False Then
numIncorrect = numIncorrect + 1
End If
qAnswered(thisQuestionNum) = True
DoingPoorly
End Sub
I Don’t Know How Many Questions:
ReDim
to the Rescue
It is very nice to cut down on the amount of VBA code that needs to be
changed, but would n’t it be nice to have the above pro cedures work without
changing any VBA code? The prob lem is that we need to know how many ques-
tions we have so we can declare and ini tialize our
qAnswered
ar ray. VBA is
very nice about this; if you don’t know how many items you need in an ar ray, it
lets you tell it whenever you know. We can declare the ar ray with the fol lowing

Download 1.37 Mb.

Do'stlaringiz bilan baham:
1   ...   134   135   136   137   138   139   140   141   ...   191




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