Adding and Counting through multiple slides

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi to All.

I am trying to create a "test" at the end of a presentation. I need to be
able to count the number of questions answered and the number of correct
answers. The last slide will be a presentation of a certificate with the
user's name and their results to be printed.

The two things that are not working are the counting of the variable and
placing the results into a textbox on the last slide as soon as the slide is
presented. The format is Scenario 1, 2 slides choosing an answer, Scenario
2, 2 slides of choosing an answer, Scenario 3, 2 slides choosing an answer,
then Four Scenarios each followed by one slide choosing an answer. The
choices are in an OptionButton Group unique for each slide.
First, I must tell you I am using PowerPoint 2000 for this.
The variables I have declared are:
Public Answer As String
Public Count, PercentCorrect As Integer

From reading some of the posts here and PPT Help, I think I will have to
change the variable Count to something else. However, when I run the script,
the variable will change between the first two slides but reset on each slide
after that.

The code I use to increase count is

Count = Count +1
PercentCorrect = PercentCorrect + 1 (0 for incorrect answers)

Thanks to all for any and all help.
 
As a general rule, it is a good idea to avoid programming keywords. While I
did not have any issue with a small routine I whipped up that used the
variable name Count, it is possible. Try changing the Count variable to
intAnswerCnt (make sure you use whole word replace). It may help.

Possible also is that the variable is being changed by something in the code
that you forgot about.

Why are you declaring the variables as Public? It may be possible that you
are running into a conflict with another routine.


--
Bill Dilworth
A proud member of the Microsoft PPT MVP Team
Users helping fellow users.
billdilworth.mvps.org
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
yahoo2@ Please read the PowerPoint
yahoo. FAQ pages. They answer most
com of our questions.
www.pptfaq.com
..
..
 
Bill:

You are absolutely right about avoiding programming keywords. As soon as I
saw it was, I knew it had to be changed. I used the Public statement because
the VBA Help states :
"Variables declared using the Public statement are available to all
procedures in all modules in all applications unless Option Private Module is
in effect; in which case, the variables are public only within the project in
which they reside."

I tried changing the variable name and still get the reset at each slide and
the last slide has the variables empty. The code for each slide, with the
only difference being which answer is set to True is:
Private Sub Slide18_Click()
intAnswerCnt = 0 'Resets intAnswerCnt to zero for beginning of test
PercentCorrect = 0 'Resets PercentCorrect to zero for beginning of test

If Title = True Then
intAnswerCnt = intAnswerCnt + 1 'Increases the question count by one
PercentCorrect = PercentCorrect + 1 'Increases the correct answer
count by one
Msg = "Correct! The correct Short Title is RIID Operator" 'Displays
the message
Response = MsgBox(Msg, vbInformation + vbOKOnly, "Correct Answer")
'Title of the message box
Response = MsgBox(PercentCorrect & ":" & intAnswerCnt,
vbInformation, "Numbers") 'Test Box to track variable values
SlideShowWindows(1).View.Next 'Moves to the next slide
Else
intAnswerCnt = intAnswerCnt + 1 'Increases the question count by one
Msg = "Incorrect. The Short Title is RIID Operator not RIID"
'Displays the message
Response = MsgBox(Msg, vbExclamation + vbOKOnly, "Incorrect Answer")
'Title of the message box
Response = MsgBox(PercentCorrect & ":" & intAnswerCnt,
vbInformation, "Numbers") 'Test Box to track numbers
SlideShowWindows(1).View.Next 'Moves to the next slide
End If 'End Block If Statement

End Sub
 
Chris,

I have examples of exactly what you are trying to do on my site. Check
out Example 7.9 on my site:

http://www.loyola.edu/education/PowerfulPowerPoint/

Click on "Examples by Chapter" and "Chapter 7." The example doesn't use
Option buttons but could easily be modified to do so.

--David
--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.loyola.edu/education/PowerfulPowerPoint/
 
David:

This post was helpful but not for the reasons you would think. The problem
was WHERE I was putting my code. Instead of creating a module, I was
attempting to do it through PowerPoint Objects. Once I moved everything to a
Module, it started counting and once I eliminated the double counting, it
started counting correctly!

Your example did help me with the presentation controls, results page, and
using action buttons.

Thank You,
 
Great. I'm glad I could help. I am not a big fan of the control toolbox,
largely because it is not cross-platform compatible. It also forces use
of multiple modules, which, as you have seen, can get confusing. I
thought I had some examples on my site that use the control toolbox, but
I couldn't find any, so if you get yours working the way you want, I
wouldn't mind if you would send it to me so I can post it on my site
(under "Examples from Real People").
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.loyola.edu/education/PowerfulPowerPoint/
 
Back
Top