Hi,
So far i have been creating questions and checking the answer by clicking on the button to show if the answers are Correct or Wrong. See code below:
Private Sub Mark_Click()
'given values: V = 5V and R = 100 Ohms
If ComboBox1 = "I = V / R" And TextBox1 = 0.05 And TextBox2 = 0.25 Then
Label1.Caption = "Correct"
Else
Label1.Caption = "Wrong"
End If
End Sub
What i want now is to make a small quiz. Instead of checking for correct and wrong answer i want to give a mark for example out of 5.
Ohm's law : I = V/R ( 2 marks)
I value found = 0.05 ( 1 mark)
Power value found 0.25 (1 mark)
By replacing the "check answer" button by "Show mark". If all answers are correct, after clicking on "show mark" it should display 5. If only the first answer is correct, it should display only 2 marks and so on. I tried my best but with no success.
Any help.
Many thanks
Nasser.
Marking Quiz
-
- StarLounger
- Posts: 56
- Joined: 11 May 2010, 10:26
Marking Quiz
You do not have the required permissions to view the files attached to this post.
-
- StarLounger
- Posts: 56
- Joined: 11 May 2010, 10:26
Re: Marking Quiz
Hi ,
Sorry : power value found ( 2 marks) :)
Regards,
Nasser.
Sorry : power value found ( 2 marks) :)
Regards,
Nasser.
-
- Administrator
- Posts: 78448
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Marking Quiz
Unless someone else replies in the meantime, I'll look at the workbook later on - although I can open it in Excel 2003, it doesn't work.
Best wishes,
Hans
Hans
-
- Administrator
- Posts: 78448
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Marking Quiz
Try this code. It handles each of the three questions separately, then assembles the caption for the label.
Code: Select all
Private Sub CommandButton1_Click()
Dim intMarks As Integer
Dim strLabel As String
If Me.ComboBox1 = "I = V / R" Then
intMarks = intMarks + 2
End If
If Me.TextBox1 = "0.05" Then
intMarks = intMarks + 1
End If
If Me.TextBox2 = "0.25" Then
intMarks = intMarks + 2
End If
strLabel = intMarks & " mark"
If intMarks <> 1 Then
strLabel = strLabel & "s"
End If
Me.Label1.Caption = strLabel
End Sub
Best wishes,
Hans
Hans