![]() |
|
#1
|
|||
|
|||
![]()
I found a site that gave some ideas for using PowerPoint for an interactive quiz, ie, when someone clicks a button, it counts if they got the question right and then gives a score at the end.
Using this code . . . Code:
Option Explicit Public Tally As Integer Sub InitializeScore() Tally = 0 End Sub Sub AddToTally(Points As Integer) Tally = Tally + Points End Sub Function ShowTally() MsgBox "Your final score is " & CStr(Tally) End Function Two questions, please: 1) How do Initialize the score without requiring someone click the button, ie, it should initialize when the Slideshow begins. 2) How do I show the person the score at the end, seeing as I can't attach it to an Action, eg, "Click here to see your score"? Thanks in advance, and if you have any suggestions for improving the above, I would naturally be happy to hear your thoughts! ![]() Cheers Brian |
#2
|
|||
|
|||
![]()
Why did you use a Function??
Just make it a Sub Sub ShowTally() MsgBox "Your final score is " & CStr(Tally) End Sub |
#3
|
|||
|
|||
![]()
I understand, after reading a few articles, that Functions can return values; Subs cannot.
![]() |
#4
|
|||
|
|||
![]()
That is true but you don't really understand what return a result means. For your use the sub will work just fine. Functions usually perform calculations and then return a result.
For example if you recorded numberCorrect and numberWrong you could return the % age correct with a Function Simple (trivial) example Code:
Sub chexPercent() Dim Correct As Long Dim Wrong As Long Correct = 3 Wrong = 4 MsgBox getpercent(Correct, Wrong) & "%" End Sub Function getpercent(numberCorrect As Long, numberWrong As Long) As Single Dim totalTried As Long totalTried = numberCorrect + numberWrong getpercent = (numberCorrect / totalTried) * 100 End Function |
#5
|
|||
|
|||
![]()
OK. Thanks again. Stupid question, but isn't 1+1 a calculation?
![]() I need to be able to assign an Action/Macro to every 'correct' answer, so that an addition occurs, and on the final slide, it will give me a total. I just tried this . . . I clicked a button that had the 'AddToTally' macro assigned. I then clicked another link that had the 'ShowTally' macro assigned. A message box appeared, saying "Your final score is 0" (obviously should've been 1). ![]() |
#6
|
|||
|
|||
![]()
If a correct answer always adds 1
Code:
Sub InitializeScore() Tally = 0 End Sub Sub AddToTally() ' this adds 1 to the score Tally = Tally + 1 End Sub Sub ShowTally() MsgBox "Your final score is " & CStr(Tally) End Sub |
#7
|
|||
|
|||
![]()
OK, thanks for the amended code, but now it just says, "Your final score is" (ie, no number).
![]() Really appreciate your help with this, by the way. ![]() |
#8
|
|||
|
|||
![]()
You left out the Public Tally I think then
Code:
Public Tally as Integer Sub InitializeScore() Tally = 0 End Sub Sub AddToTally() ' this adds 1 to the score Tally = Tally + 1 End Sub Sub ShowTally() MsgBox "Your final score is " & CStr(Tally) End Sub |
#9
|
|||
|
|||
![]()
Thanks. That's working now.
Is there a way to initialize the score without someone having to click something, ie, OnLoad, BeforeUpdate, etc? You're a star! ![]() |
#10
|
|||
|
|||
![]()
Try this
Code:
Sub OnSlideShowPageChange(SW As SlideShowWindow) If SW.View.CurrentShowPosition = 1 Then Call InitializeScore End Sub |
#11
|
|||
|
|||
![]()
Sorry for being obtuse, but doesn't adding this to a Command Button mean that someone has to click the button in order for it to initialize?
Thanks in advance for clarifying. |
![]() |
Tags |
quiz, score |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Exporting quiz scores from powerpoint to excel spreadsheet/word | rjagile | PowerPoint | 1 | 02-08-2016 02:26 PM |
Ad a quiz with different scores for each question and with final score at the end | Amadeus | PowerPoint | 0 | 09-16-2014 04:24 AM |
![]() |
TerryStevenson | Excel | 1 | 09-16-2013 12:20 PM |
![]() |
TimC | PowerPoint | 3 | 07-08-2013 11:33 PM |
Keeping scores in ppt, please please help | piper7971 | PowerPoint | 0 | 07-24-2010 07:10 PM |