View Single Post
 
Old 03-28-2023, 01:33 PM
NoSparks NoSparks is offline Windows 10 Office 2010
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 831
NoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really nice
Default

try
Code:
Private Sub cmdSubmit_Click()
    Dim lRow As Integer

'Check if user click an option
If cmdA.BackColor = &HFF00& Or cmdB.BackColor = &HFF00& Or _
   cmdC.BackColor = &HFF00& Or cmdD.BackColor = &HFF00& Then
    
    'Move to the next question
    questionNo = questionNo + 1
    Label1.Caption = "Question " & questionNo & " of 10"
    
    If cmdSubmit.Caption = "Submit" Then
        lRow = rSH.Range("A" & Rows.Count).End(xlUp).Row + 1
        
        rSH.Range("C" & lRow).Value = rSH.Range("C" & lRow).Value + 1
        'rSH.Range("Y1").Value = frm_score.lblScore
        txtSampleCode.Text = rSH.Range("C" & lRow).Value
        
        Call get_quiz
        
    ElseIf cmdSubmit.Caption = "End Exam" Then

        'Save the quiz result to record sheet
        lRow = rSH.Range("A" & Rows.Count).End(xlUp).Row + 1
        rSH.Range("A" & lRow).Value = username
        rSH.Range("B" & lRow).Value = Now

        frm_score.lblName = username
        frm_score.lblScore = rSH.Range("C" & lRow).Value + 1
        frm_score.Show
        Unload Me
    End If

Else
    MsgBox "Please select an answer.", vbExclamation, mTitle
End If

End Sub
Reply With Quote