VBA Code and Powerpoint 2016

Anonymous
2016-05-28T03:19:25+00:00

Hi,

Can anyone help me to write a Visual Basic Code for Multiple Choice quiz, where I can check the final score.

I have used the YouTube help , but somehow the codes give error when running in PP2016.

I used the following code:

Sub QUIZ101()

Dim UserName As String

Dim numberCorrect As Integer

Dim numberWrong As Integer

Sub YourName( )

UserName = InputBox(Prompt, "Type Your Name!")

MsgBox "Welcome to PM4S Math Quiz" + UserName, vbApplicationModal, "QUIZ101"

End Sub

Sub Correct( )

MsgBox "Well Done! That's Correct" + UserName, vbApplicationModal, "QUIZ101"

numberCorrect = numberCorrect + 1

ActivePresentation.SlideShowWindow.View.Next

End Sub

Sub Wrong( )

MsgBox "Sorry, That's Incorrect" + UserName, vbApplicationModal, "QUIZ101"

numberWrong = numberWrong + 1

ActivePresentation.SlideShowWindow.View.Next

End Sub

Sub Start( )

numberCorrect = 0

Number Wrong = 0

YourName

ActivePresentation.SlideShowWindow.View.Next

End Sub

Sub Results( )

MsgBox ("You Got numberCorrect & 'out of " & numberCorrect + numberWrong & ", " & UserName), vbApplicationModal, "QUIZ101"

End Sub

Thanks a million

Microsoft 365 and Office | PowerPoint | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes

5 answers

Sort by: Most helpful
  1. Anonymous
    2016-05-28T12:37:55+00:00

    On a quick look, I see an extra space between Number and Wrong in the Start procedure. 

    You might check out my site for several working examples. 

    http://www.PowerfulPowerPoint.com/

    Go to Examples By Chapter and Chapter 8 for several quiz examples.

    0 comments No comments
  2. Steve Rindsberg 99,086 Reputation points MVP Volunteer Moderator
    2016-05-28T14:12:50+00:00

    MsgBox ("You Got numberCorrect & 'out of " & numberCorrect + numberWrong & ", " & UserName), vbApplicationModal, "QUIZ101"

    should be

    MsgBox ("You Got " & numberCorrect & " out of " & numberCorrect + numberWrong & ", " & UserName), vbApplicationModal, "QUIZ101"

    Also, before running the code, try compiling it.

    0 comments No comments
  3. Anonymous
    2016-05-28T17:14:36+00:00

    Thank you very much for suggestion.

    Will try he suggestion.

    VK

    0 comments No comments
  4. Anonymous
    2016-05-28T17:19:03+00:00

    Thanks a million David.

    I will definitely look at the link you suggested.

    Will keep you posted of the progress I make.

    I am trying to build Math Quizzes for teachers to use as they finish teaching etc. and

    students to see their own understanding.

    Thanks once again

    VK

    1 person found this answer helpful.
    0 comments No comments
  5. Anonymous
    2016-06-05T18:48:45+00:00

    On a quick look, I see an extra space between Number and Wrong in the Start procedure. 

    You might check out my site for several working examples. 

    http://www.PowerfulPowerPoint.com/

    Go to Examples By Chapter and Chapter 8 for several quiz examples. 

    Hi David,

    Hi I got this VBA & PPT sorted out OK.

    I am looking now at the possibility of:

    a) adding percent score card

    b) ability to print the result with the students name.

    w.r.t. b) any input will be appreciated.

    Thanks

    VKS1946

    1 person found this answer helpful.
    0 comments No comments