Consulting

Results 1 to 4 of 4

Thread: Need help with Objective Type questions (Quiz)

  1. #1

    Exclamation Need help with Objective Type questions (Quiz)

    Dear Professionals,

    I am a DIYer and I am still learning VBA. Using different function found online, I build a Quiz. It is working but there is one thing I can't figure out. What I need is when a person pick his/her answer, user form must show(highlight in green) him the correct answer, so that a person knows if he/she answered correctly, before clicking next button .
    I attached screenshots of my userform and this is my code:

    Private Sub Button_Click()
    If (Answer1.Value = True) Then
        ans = 1
    ElseIf (Answer2.Value = True) Then
        ans = 2
    ElseIf (Answer3.Value = True) Then
        ans = 3
    ElseIf (Answer4.Value = True) Then
        ans = 4
    End If
    ansacc = CInt(Range("Questions!F" & Counter).Text)
    If (ansacc = ans) Then
        status.Width = status.Width + 1
    
    End If
    
    Answer1.Value = False
    Answer2.Value = False
    Answer3.Value = False
    Answer4.Value = False
    Counter = Counter + 1
    qcounter = qcounter + 1
    If qcounter <= 50 Then
    While (Range("Questions!G" & Counter).Text <> "A")
        Counter = Counter + 1
    Wend
    Question.Caption = Range("Questions!A" & Counter).Text
    Answer1.Caption = Range("Questions!B" & Counter).Text
    Answer2.Caption = Range("Questions!C" & Counter).Text
    Answer3.Caption = Range("Questions!D" & Counter).Text
    Answer4.Caption = Range("Questions!E" & Counter).Text
    End If
    Counterq.Caption = Range("Count!A5").Value
    Range("Count!D1").Value = status.Width
    Button.Enabled = False
    
    If qcounter < 50 Then
    Frame1.Visible = False
    Label2.Visible = False
    correct.Visible = False
    Label3.Visible = False
    rate.Visible = False
    Label4.Visible = False
    EOC.Visible = False
    Label5.Visible = False
    preeoc.Visible = False
    End If
    
    If qcounter = 50 Then
    Frame1.Visible = True
    Label2.Visible = True
    correct.Visible = True
    Label3.Visible = True
    rate.Visible = True
    Label4.Visible = True
    EOC.Visible = True
    Label5.Visible = True
    preeoc.Visible = True
    
    correct.Caption = Range("Count!D1").Value
    rate.Caption = Range("Count!D2").Value
    EOC.Caption = Range("Count!D3").Value
    preeoc.Caption = Range("Count!D4").Value
    Button.Enabled = False
    
    End If
    
    End Sub
    Attached Images Attached Images
    Last edited by Bob Phillips; 06-04-2020 at 01:23 AM. Reason: Added code tags

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    That screenshot is illegible. A workbook would help much more.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3

    Exclamation Need help with Objective Type Questions (quiz)

    Dear Professionals,

    I am a DIYer and I am still learning VBA. Using different function found online, I build a Quiz. It is working but there is one thing I can't figure out. What I need is when a person pick his/her answer, user form must show(highlight in green) the correct answer, so that a person knows if he/she answered correctly, before clicking next button .
    File is attached
    Attached Files Attached Files

  4. #4
    My project is based on this File code. I changed it a little bit, but they do the same

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •