D
Dianne Aldridge
I've created a simple game consisting of 19 slides:
1 title slide
1 instruction slide
15 question slides
1 sorry slide
1 congratulations/certificate slide
Everything works fine except that when I finish answering all of the
questions and go to either the sorry or congratulations slide
(depending on the score) the PP immediately attempts to go to a next
slide; there is no next slide, so I'm kicked out of the show. I've
played with this for hours, retyped the code, tried a few variations of
the code, and still cannot figure out why PP is trying to advance
slides when there is no ActivePresentation.SlideShowWindow.View.Next
line telling it to do so. Please see my code below.
Question: I call the sorry and congratulations subroutines from within
an If/Then structure. Is the code returning to that structure after it
executes the lines in the called subroutine? There is a
ActivePresentation.SlideShowWindow.View.Next statement beneath the
If/Then.
Dim StudentName As String
Dim HaveName As Boolean
Dim NumCorrect As Integer
Dim NumIncorrect As Integer
Sub StartGame()
NumCorrect = 0
NumIncorrect = 0
HaveName = False
While Not HaveName
StudentName = InputBox(prompt:="Please type your name in the
space below", Title:="Student Name")
If StudentName = "" Then
HaveName = False
Else
HaveName = True
End If
Wend
ActivePresentation.SlideShowWindow.View.GotoSlide (2)
End Sub
Sub RightAnswer()
NumCorrect = NumCorrect + 1
If NumCorrect = 15 Then
MsgBox ("Amazing! A Perfect Score, " & StudentName & "!")
ElseIf NumCorrect >= 10 Then
MsgBox ("Great job! Keep it up, " & StudentName & "!")
ElseIf NumCorrect >= 5 Then
MsgBox ("That's correct, " & StudentName & "!")
ElseIf NumCorrect >= 1 Then
MsgBox ("That's the right answer, " & StudentName & "!")
End If
If ActivePresentation.SlideShowWindow.View.Slide.Name =
"LastQuestion" Then
If NumCorrect >= 10 Then
Congratulations
Else
Sorry
End If
End If
ActivePresentation.SlideShowWindow.View.Next
ActivePresentation.SlideShowWindow.View.Slide.Shapes("CorrectScoreBox").TextFrame.TextRange.Text
= NumCorrect
ActivePresentation.SlideShowWindow.View.Slide.Shapes("IncorrectScoreBox").TextFrame.TextRange.Text
= NumIncorrect
End Sub
Sub WrongAnswer()
NumIncorrect = NumIncorrect + 1
If NumIncorrect >= 10 Then
MsgBox ("Sorry, that's not the right answer, " & StudentName &
".")
ElseIf NumIncorrect >= 5 Then
MsgBox ("This is not the correct answer. Keep trying, " &
StudentName & ".")
ElseIf NumIncorrect >= 1 Then
MsgBox ("Oops, you missed that one, " & StudentName & ".")
End If
If ActivePresentation.SlideShowWindow.View.Slide.Name =
"LastQuestion" Then
If NumCorrect >= 10 Then
Congratulations
Else
Sorry
End If
End If
ActivePresentation.SlideShowWindow.View.Next
ActivePresentation.SlideShowWindow.View.Slide.Shapes("CorrectScoreBox").TextFrame.TextRange.Text
= NumCorrect
ActivePresentation.SlideShowWindow.View.Slide.Shapes("IncorrectScoreBox").TextFrame.TextRange.Text
= NumIncorrect
End Sub
Sub Congratulations()
ActivePresentation.SlideShowWindow.View.GotoSlide (19)
ActivePresentation.SlideShowWindow.View.Slide.Shapes("CertStudentName").TextFrame.TextRange.Text
= StudentName
MsgBox ("Congratulations! Here is your certificate, " & StudentName
& ". Be sure to print it.")
End Sub
Sub Sorry()
ActivePresentation.SlideShowWindow.View.GotoSlide (18)
End Sub
Sub PrintCertificate()
ActivePresentation.Slides(19).Shapes("PrintButton").Visible = False
ActivePresentation.Slides(19).Shapes("MenuButton").Visible = False
ActivePresentation.PrintOptions.OutputType = ppPrintOutputSlides
ActivePresentation.PrintOut From:=19, To:=19
End Sub
1 title slide
1 instruction slide
15 question slides
1 sorry slide
1 congratulations/certificate slide
Everything works fine except that when I finish answering all of the
questions and go to either the sorry or congratulations slide
(depending on the score) the PP immediately attempts to go to a next
slide; there is no next slide, so I'm kicked out of the show. I've
played with this for hours, retyped the code, tried a few variations of
the code, and still cannot figure out why PP is trying to advance
slides when there is no ActivePresentation.SlideShowWindow.View.Next
line telling it to do so. Please see my code below.
Question: I call the sorry and congratulations subroutines from within
an If/Then structure. Is the code returning to that structure after it
executes the lines in the called subroutine? There is a
ActivePresentation.SlideShowWindow.View.Next statement beneath the
If/Then.
Dim StudentName As String
Dim HaveName As Boolean
Dim NumCorrect As Integer
Dim NumIncorrect As Integer
Sub StartGame()
NumCorrect = 0
NumIncorrect = 0
HaveName = False
While Not HaveName
StudentName = InputBox(prompt:="Please type your name in the
space below", Title:="Student Name")
If StudentName = "" Then
HaveName = False
Else
HaveName = True
End If
Wend
ActivePresentation.SlideShowWindow.View.GotoSlide (2)
End Sub
Sub RightAnswer()
NumCorrect = NumCorrect + 1
If NumCorrect = 15 Then
MsgBox ("Amazing! A Perfect Score, " & StudentName & "!")
ElseIf NumCorrect >= 10 Then
MsgBox ("Great job! Keep it up, " & StudentName & "!")
ElseIf NumCorrect >= 5 Then
MsgBox ("That's correct, " & StudentName & "!")
ElseIf NumCorrect >= 1 Then
MsgBox ("That's the right answer, " & StudentName & "!")
End If
If ActivePresentation.SlideShowWindow.View.Slide.Name =
"LastQuestion" Then
If NumCorrect >= 10 Then
Congratulations
Else
Sorry
End If
End If
ActivePresentation.SlideShowWindow.View.Next
ActivePresentation.SlideShowWindow.View.Slide.Shapes("CorrectScoreBox").TextFrame.TextRange.Text
= NumCorrect
ActivePresentation.SlideShowWindow.View.Slide.Shapes("IncorrectScoreBox").TextFrame.TextRange.Text
= NumIncorrect
End Sub
Sub WrongAnswer()
NumIncorrect = NumIncorrect + 1
If NumIncorrect >= 10 Then
MsgBox ("Sorry, that's not the right answer, " & StudentName &
".")
ElseIf NumIncorrect >= 5 Then
MsgBox ("This is not the correct answer. Keep trying, " &
StudentName & ".")
ElseIf NumIncorrect >= 1 Then
MsgBox ("Oops, you missed that one, " & StudentName & ".")
End If
If ActivePresentation.SlideShowWindow.View.Slide.Name =
"LastQuestion" Then
If NumCorrect >= 10 Then
Congratulations
Else
Sorry
End If
End If
ActivePresentation.SlideShowWindow.View.Next
ActivePresentation.SlideShowWindow.View.Slide.Shapes("CorrectScoreBox").TextFrame.TextRange.Text
= NumCorrect
ActivePresentation.SlideShowWindow.View.Slide.Shapes("IncorrectScoreBox").TextFrame.TextRange.Text
= NumIncorrect
End Sub
Sub Congratulations()
ActivePresentation.SlideShowWindow.View.GotoSlide (19)
ActivePresentation.SlideShowWindow.View.Slide.Shapes("CertStudentName").TextFrame.TextRange.Text
= StudentName
MsgBox ("Congratulations! Here is your certificate, " & StudentName
& ". Be sure to print it.")
End Sub
Sub Sorry()
ActivePresentation.SlideShowWindow.View.GotoSlide (18)
End Sub
Sub PrintCertificate()
ActivePresentation.Slides(19).Shapes("PrintButton").Visible = False
ActivePresentation.Slides(19).Shapes("MenuButton").Visible = False
ActivePresentation.PrintOptions.OutputType = ppPrintOutputSlides
ActivePresentation.PrintOut From:=19, To:=19
End Sub