PDA

View Full Version : Figuring out percentages at the end of a quiz.



johnwatkins3
11-22-2012, 10:03 AM
hello all,
i need a little help here. i have a ppt 2007 quiz that will give me the number right and wrong. but what i need is for it to figure out the percentage.

John Wilson
11-22-2012, 10:13 AM
Assuming iTotal and iCorrect hold the total number of questions and the number correct:

MsgBox "percent correct = " & Round((iCorrect / iTotal) * 100, 2)

This is rounded to 2 decimal places

johnwatkins3
11-22-2012, 10:34 AM
i placed it in there but did nothing here is the code:
Dim numCorrect As Integer
Dim numIncorrect As Integer
Dim userName As String

Sub GetStarted()
Initialize
YourName
ActivePresentation.SlideShowWindow.View.Next
End Sub

Sub Initialize()
numCorrect = 0
numIncorrect = 0
End Sub

Sub YourName()
userName = InputBox("Type your name")
End Sub

Sub RightAnswer()
numCorrect = numCorrect + 1
MsgBox "You are doing well, " & userName
ActivePresentation.SlideShowWindow.View.Next
End Sub

Sub WrongAnswer()
numIncorrect = numIncorrect + 1
MsgBox "Try to do better next time, " & userName
ActivePresentation.SlideShowWindow.View.Next
End Sub

Sub Feedback()
MsgBox "You got " & numCorrect & " out of " _
& numCorrect + numIncorrect & ", " & userName
MsgBox "percent correct = " & Round((numCorrect / numTotal) * 100, 2)
End Sub

John Wilson
11-22-2012, 01:15 PM
You didn't calculate the numtotal.

Sub Feedback()
Dim numTotal As Integer
numTotal = numCorrect + numIncorrect
MsgBox "You got " & numCorrect & " out of " _
& numTotal & ", " & userName
MsgBox "percent correct = " & Round((numCorrect / numTotal) * 100, 2)
End Sub

johnwatkins3
11-22-2012, 02:19 PM
thanks for that but what if i wanna have it on a slide ex. a certificate

johnwatkins3
11-22-2012, 03:28 PM
another thing if i had a 50 question test would i copy and paste this 50 times:

Sub RightAnswer()
numCorrect = numCorrect + 1
MsgBox "You are doing well, " & userName
ActivePresentation.SlideShowWindow.View.Next
End Sub

Sub WrongAnswer()
numIncorrect = numIncorrect + 1
MsgBox "Try to do better next time, " & userName
ActivePresentation.SlideShowWindow.View.Next
End Sub

John Wilson
11-23-2012, 01:49 AM
Assuming that you entered the code in a standard module then NO. Just mke each button or shape run that code. DO NOT use command buttons just normal Action Buttons or Shapes.

johnwatkins3
12-09-2012, 05:52 PM
John,
Can you do me a favor and check out this PPT Quiz i put together? the questions have hyperlinks. i just need for the results to be placed on the certificate, along with their name and date from slide 1.

John Wilson
12-11-2012, 01:41 AM
I'm real busy with a major project right now.

You need to make variables you use in several modules Public
You need to make the shapes names on the certificate something easy to find.
To see the code for the input name right click > view code

I have done this (http://www.pptalchemy.co.uk/Downloads/Test (ver.2).pptm)but you will have to work through the code yourself.

johnwatkins3
12-11-2012, 06:07 AM
thanks John good luck on your project

johnwatkins3
01-15-2013, 11:16 AM
at the end of the ppt test that you helped me with how can i create a button to print out the certificate?

John Wilson
01-15-2013, 11:36 PM
There's a tutorial on this on our site in the vba section

"Print Current slide" (http://www.pptalchemy.co.uk/powerpoint_hints_and_tips_tutorials.html#vba)

johnwatkins3
01-16-2013, 05:41 AM
thanks john for the quick response