M
MoWoL
Many thanks to everyone who has helped me so far. I was hoping to once again
get pointed in the right direction. I have a power point for user practice
that gives the slides in random order, and when the question is answered
incorrectly, the slide will come up again, once correct, it no longer comes
up. This code was adapted from Mr. Marcovitz's web site and works beautifuly.
I have tried to incorporate scoring on the power point, and want it to only
count the answer the first time it comes up. (If they get it wrong once, it's
counted as wrong even though they will face the question again.) I have tried
using the qAnswered array found on the site, but it won't work. I think maybe
because I already have the visited array keeping the randomization working
properly. (Can you have two arrays in code?) I am new to VBA, but love
playing with it. The following code works but counts incorrect every time
they may get it wrong, not just the first. Thanks again for any input you may
have.
Dim visited() As Boolean
Dim numSlides As Long
Dim numRead As Integer
Dim NumCorrect As Integer
Dim NumIncorrect As Integer
Sub GetStarted()
Initialize
MakeAllNotVisible
RandomNext
End Sub
Sub Initialize()
Randomize
numRead = 0
NumCorrect = 0
NumIncorrect = 0
numSlides = ActivePresentation.Slides.Count
ReDim visited(numSlides)
For i = 2 To numSlides - 1
visited(i) = False
Next i
End Sub
Sub MakeAllNotVisible()
Dim oSld As Slide
Dim oShp As Shape
For Each oSld In ActivePresentation.Slides
For Each oShp In oSld.Shapes
If oShp.Name = "Missed" Then
oShp.Visible = False
End If
Next oShp
Next oSld
End Sub
Sub RightAnswer()
NumCorrect = NumCorrect + 1
visited(ActivePresentation.SlideShowWindow.View.Slide.SlideIndex) = True
numRead = numRead + 1
RandomNext
End Sub
Sub WrongAnswer()
NumIncorrect = NumIncorrect + 1
ActivePresentation.SlideShowWindow.View.Slide.Shapes("Missed").Visible =
True
ActivePresentation.SlideShowWindow.View.GotoSlide (2)
End Sub
Sub RandomNext()
Dim nextSlide As Long
If numRead >= numSlides - 3 Then
ActivePresentation.SlideShowWindow.View.Last
Else
nextSlide = Int((numSlides - 2) * Rnd + 2)
While visited(nextSlide) = True Or nextSlide = 2
nextSlide = Int((numSlides - 2) * Rnd + 2)
Wend
ActivePresentation.SlideShowWindow.View.GotoSlide (nextSlide)
End If
End Sub
get pointed in the right direction. I have a power point for user practice
that gives the slides in random order, and when the question is answered
incorrectly, the slide will come up again, once correct, it no longer comes
up. This code was adapted from Mr. Marcovitz's web site and works beautifuly.
I have tried to incorporate scoring on the power point, and want it to only
count the answer the first time it comes up. (If they get it wrong once, it's
counted as wrong even though they will face the question again.) I have tried
using the qAnswered array found on the site, but it won't work. I think maybe
because I already have the visited array keeping the randomization working
properly. (Can you have two arrays in code?) I am new to VBA, but love
playing with it. The following code works but counts incorrect every time
they may get it wrong, not just the first. Thanks again for any input you may
have.
Dim visited() As Boolean
Dim numSlides As Long
Dim numRead As Integer
Dim NumCorrect As Integer
Dim NumIncorrect As Integer
Sub GetStarted()
Initialize
MakeAllNotVisible
RandomNext
End Sub
Sub Initialize()
Randomize
numRead = 0
NumCorrect = 0
NumIncorrect = 0
numSlides = ActivePresentation.Slides.Count
ReDim visited(numSlides)
For i = 2 To numSlides - 1
visited(i) = False
Next i
End Sub
Sub MakeAllNotVisible()
Dim oSld As Slide
Dim oShp As Shape
For Each oSld In ActivePresentation.Slides
For Each oShp In oSld.Shapes
If oShp.Name = "Missed" Then
oShp.Visible = False
End If
Next oShp
Next oSld
End Sub
Sub RightAnswer()
NumCorrect = NumCorrect + 1
visited(ActivePresentation.SlideShowWindow.View.Slide.SlideIndex) = True
numRead = numRead + 1
RandomNext
End Sub
Sub WrongAnswer()
NumIncorrect = NumIncorrect + 1
ActivePresentation.SlideShowWindow.View.Slide.Shapes("Missed").Visible =
True
ActivePresentation.SlideShowWindow.View.GotoSlide (2)
End Sub
Sub RandomNext()
Dim nextSlide As Long
If numRead >= numSlides - 3 Then
ActivePresentation.SlideShowWindow.View.Last
Else
nextSlide = Int((numSlides - 2) * Rnd + 2)
While visited(nextSlide) = True Or nextSlide = 2
nextSlide = Int((numSlides - 2) * Rnd + 2)
Wend
ActivePresentation.SlideShowWindow.View.GotoSlide (nextSlide)
End If
End Sub