Sub btnNext_Click
Dim Result As Int
Counter = Counter + 1
Qnumber = Rnd(1, 95)
lblQuestion.Text = QuestionList.Get(Qnumber) 'display a random question every time.
If Qnumber >= 95 Then
Qnumber = 0
End If
' If Counter = 10 Then 'if ten questions have passed then display message box with correct and wrong answers.
' Result = Msgbox2("You have answered 8 correct out of 10", "Score", "Continue", "Finish", "", Null)
' Counter = 0
'End If
rbtAnswer(0).Checked = False 'uncheck all option buttons
rbtAnswer(1).Checked = False
rbtAnswer(2).Checked = False
opt1 = Rnd(0, 3)
opt2 = Rnd(0, 3)
opt3 = Rnd(0, 3)
If opt1 = opt2 OR opt1 = opt3 OR opt2 = opt3 Then 'make sure opt1 or opt2 or opt3 are not equals to each other
Do While opt1 = opt2 OR opt2 = opt3 OR opt3 = opt1 'if any of them are then randomize again, until none of them are equal
opt1 = Rnd(0, 3)
opt2 = Rnd(0, 3)
opt3 = Rnd(0, 3)
Loop
rbtAnswer(opt1).Text = AnswerList1.Get(Qnumber) 'assign that specific number 0 to 2 once they are unique
rbtAnswer(opt2).Text = AnswerList2.Get(Qnumber) 'that way each answer will be assigned to any option button every time
rbtAnswer(opt3).Text = AnswerList3.Get(Qnumber) 'no same answer will be on the same position every time.
Log(opt1 & " " & opt2 & " " & opt3)
Else
rbtAnswer(opt1).Text = AnswerList1.Get(Qnumber)
rbtAnswer(opt2).Text = AnswerList2.Get(Qnumber)
rbtAnswer(opt3).Text = AnswerList3.Get(Qnumber)
Log(opt1 & " " & opt2 & " " & opt3)
End If
correctAnswer = AnswerList1.Get(Qnumber) 'assign the correct answer to variable correctAnswer.
End Sub