For Loop question

hello Masters,

How are you all doing? I just have a question.

I am building this simple quiz application using asp.net/vb.net and sql server for the database. Now what I want to happen is that when I click on submit button, it will count all the correct answers of the user based on the radio button he clicks.

I have two radio buttons and the correct answer for those two radio buttons is A, now if they click both A for those 2 radio buttons, they will get a score of two else if wrong, it won't count the incorrect answer.

Here is what I got: (I am very sorry for the messy code, I am new to loops)

Dim score As Integer = 0

If RbAnswers1.SelectedValue = "A" Then

For score = 0 To lbCorrectAnswerCount.Text.Count - 1

score += 1

Next score
If RbAnswers2.SelectedValue = "A" Then
Else
lbCorrectAnswerCount.Text = score
Exit Sub
End If
Else
Exit Sub
lbCorrectAnswerCount.Text = score

End If

lbCorrectAnswerCount.Text = score

Thank you in advance for your help.
Sign In or Register to comment.