INTERACTIVE QUIZ - VB CODE

Dim
numCorrect As Integer
Dim
numIncorrect As Integer
Dim userName
As String
Dim
qAnswered As Boolean

Sub
SaveToExcel() 'ADDED
    Dim oXLApp As Object
    Dim oWb As Object
    Dim row As Long
   
    Set oXLApp =
CreateObject("Excel.Application")
    'On a Mac change \ to : in the following
line
    Set oWb =
oXLApp.Workbooks.Open(ActivePresentation.Path & "\" &
"Results.xlsx")
    If oWb.Worksheets(1).Range("A1")
= "" Then
        oWb.Worksheets(1).Range("A1")
= "Name"
        oWb.Worksheets(1).Range("B1")
= "Number Correct"
        oWb.Worksheets(1).Range("C1")
= "Number Incorrect"
        oWb.Worksheets(1).Range("D1")
= "Percentage"
    End If
    row = 2
    While oWb.Worksheets(1).Range("A"
& row) <> ""
        row = row + 1
    Wend
    oWb.Worksheets(1).Range("A" &
row) = userName
    oWb.Worksheets(1).Range("B" &
row) = numCorrect
    oWb.Worksheets(1).Range("C" &
row) = numIncorrect
    oWb.Worksheets(1).Range("D" &
row) = 100 * (numCorrect / (numCorrect + numIncorrect))
   
    oWb.Save
    oWb.Close
End Sub

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

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

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

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

Sub
WrongAnswer()
    If qAnswered = False Then
        numIncorrect = numIncorrect + 1
    End If
    qAnswered = True
    MsgBox "Try to do better next time,
" & userName
End Sub

Sub
Question1()
    Dim answer As String
   
    answer = InputBox(Prompt:="What is the
capital of India?", _
        Title:="Question 1")
    If answer = "newdelhi" Then
        RightAnswer
    Else
        WrongAnswer
    End If
End Sub


Sub
Feedback()
    MsgBox "You got " &
numCorrect & " out of " _
        & numCorrect + numIncorrect &
", " & userName
    SaveToExcel 'ADDED
End Sub