Hi All,
I am hoping someone can help me with this and/or point me in the right direction.
I am developing a quiz application and have run into a problem when the question being pulled from the database is a true/false question it produces an error, straight multiple choice questions are working fine.
Here are the variable declerations I am using:
'Declare our varaiables
Dim inc As Integer
Public MaxRows As Integer
Dim con As New OleDb.OleDbConnection
Dim dbProvider As String
Dim dbSource As String
Dim ds As New DataSet
Dim da As New OleDb.OleDbDataAdapter
Dim sql As String
Dim cmd As OleDbCommand
Dim NextTime As Date = Now
Dim score As Integer
Dim tbTable As String
Dim qnum As Integer = "1" 'Sets up variable to hold what question number the user is currently on
Here is the section of code I belive is the problem.
Private Sub cmdNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdNext.Click
'Check to see if current answer is correct
'If so increment the score counter accordingly
If RadioButton1.Checked = True Then
If RadioButton1.Text = ds.Tables("Test").Rows(inc).Item(6) Then
score = score + 1
Label3.Text = score / MaxRows * 100 'Score divided by questions *100
Else
MsgBox("The correct answer is: " + ds.Tables("Test").Rows(inc).Item(6), MsgBoxStyle.Exclamation)
End If
ElseIf RadioButton2.Checked = True Then
If RadioButton2.Text = ds.Tables("Test").Rows(inc).Item(6) Then
score = score + 1
Label3.Text = score / MaxRows * 100
Else
MsgBox("The correct answer is: " + ds.Tables("Test").Rows(inc).Item(6), MsgBoxStyle.Exclamation)
End If
ElseIf RadioButton3.Checked = True Then
If RadioButton3.Text = ds.Tables("Test").Rows(inc).Item(6) Then
score = score + 1
Label3.Text = score / MaxRows * 100
Else
MsgBox("The correct answer is: " + ds.Tables("Test").Rows(inc).Item(6), MsgBoxStyle.Exclamation)
End If
ElseIf RadioButton4.Checked = True Then
If RadioButton4.Text = ds.Tables("Test").Rows(inc).Item(6) Then
score = score + 1
Label3.Text = score / MaxRows * 100
Else
MsgBox("The correct answer is: " + ds.Tables("Test").Rows(inc).Item(6), MsgBoxStyle.Exclamation)
End If
End If
'Move one record forward
If inc <> MaxRows - 1 Then
inc = inc + 1
NavigateRecords()
Else
MsgBox("The test has been completed")
Me.Hide()
Results.Show()
End If
End Sub
and finally - I would aldo like to keep track of the questions that have been answered incorrectly and display them to the test taker at the end of the program, but not sure how to go about doing this. Any help, and guidance is greatly appreciated.