Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-04-2016, 11:15 AM
VisionAvenger VisionAvenger is offline Interactive Quiz with Scores at the end? Windows 10 Interactive Quiz with Scores at the end? Office 2013
Novice
Interactive Quiz with Scores at the end?
 
Join Date: Mar 2016
Posts: 16
VisionAvenger is on a distinguished road
Question Interactive Quiz with Scores at the end?

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
This is good, but I can't connect an Action button to the Function (only a Sub), so I'm not sure if it's working.

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
Reply With Quote
  #2  
Old 03-04-2016, 11:41 AM
JohnWilson JohnWilson is offline Interactive Quiz with Scores at the end? Windows 7 64bit Interactive Quiz with Scores at the end? Office 2010 32bit
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,913
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

Why did you use a Function??

Just make it a Sub

Sub ShowTally()
MsgBox "Your final score is " & CStr(Tally)
End Sub
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #3  
Old 03-07-2016, 05:34 AM
VisionAvenger VisionAvenger is offline Interactive Quiz with Scores at the end? Windows 10 Interactive Quiz with Scores at the end? Office 2013
Novice
Interactive Quiz with Scores at the end?
 
Join Date: Mar 2016
Posts: 16
VisionAvenger is on a distinguished road
Default

I understand, after reading a few articles, that Functions can return values; Subs cannot.
Reply With Quote
  #4  
Old 03-07-2016, 08:07 AM
JohnWilson JohnWilson is offline Interactive Quiz with Scores at the end? Windows 7 64bit Interactive Quiz with Scores at the end? Office 2010 32bit
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,913
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

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
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #5  
Old 03-07-2016, 08:21 AM
VisionAvenger VisionAvenger is offline Interactive Quiz with Scores at the end? Windows 10 Interactive Quiz with Scores at the end? Office 2013
Novice
Interactive Quiz with Scores at the end?
 
Join Date: Mar 2016
Posts: 16
VisionAvenger is on a distinguished road
Default

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).
Reply With Quote
  #6  
Old 03-07-2016, 09:00 AM
JohnWilson JohnWilson is offline Interactive Quiz with Scores at the end? Windows 7 64bit Interactive Quiz with Scores at the end? Office 2010 32bit
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,913
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

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
With your original code (unless there was more than you posted) 'Points' was always zero and the result would always be zero
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #7  
Old 03-07-2016, 09:44 AM
VisionAvenger VisionAvenger is offline Interactive Quiz with Scores at the end? Windows 10 Interactive Quiz with Scores at the end? Office 2013
Novice
Interactive Quiz with Scores at the end?
 
Join Date: Mar 2016
Posts: 16
VisionAvenger is on a distinguished road
Default

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.
Reply With Quote
  #8  
Old 03-07-2016, 10:36 AM
JohnWilson JohnWilson is offline Interactive Quiz with Scores at the end? Windows 7 64bit Interactive Quiz with Scores at the end? Office 2010 32bit
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,913
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

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
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #9  
Old 03-07-2016, 11:14 AM
VisionAvenger VisionAvenger is offline Interactive Quiz with Scores at the end? Windows 10 Interactive Quiz with Scores at the end? Office 2013
Novice
Interactive Quiz with Scores at the end?
 
Join Date: Mar 2016
Posts: 16
VisionAvenger is on a distinguished road
Default

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!
Reply With Quote
  #10  
Old 03-07-2016, 11:40 AM
JohnWilson JohnWilson is offline Interactive Quiz with Scores at the end? Windows 7 64bit Interactive Quiz with Scores at the end? Office 2010 32bit
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,913
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

Try this
Code:
Sub OnSlideShowPageChange(SW As SlideShowWindow)
If SW.View.CurrentShowPosition = 1 Then Call InitializeScore
End Sub
To make this reliable add a CommandButton (or anything from the controls toolbox) on slide 1 and set it to not visible in the selection pane
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #11  
Old 03-08-2016, 05:40 AM
VisionAvenger VisionAvenger is offline Interactive Quiz with Scores at the end? Windows 10 Interactive Quiz with Scores at the end? Office 2013
Novice
Interactive Quiz with Scores at the end?
 
Join Date: Mar 2016
Posts: 16
VisionAvenger is on a distinguished road
Default

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.
Reply With Quote
Reply

Tags
quiz, score



Similar Threads
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
Interactive Quiz with Scores at the end? Scores returning ranked results TerryStevenson Excel 1 09-16-2013 12:20 PM
Interactive Quiz with Scores at the end? Interactive Quiz using PPT 2010 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

Other Forums: Access Forums

All times are GMT -7. The time now is 11:45 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft