-
Dec 9th, 2014, 07:05 AM
#1
Thread Starter
Member
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)
Code:
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.
Last edited by dday9; Dec 9th, 2014 at 10:15 AM.
-
Dec 9th, 2014, 10:18 AM
#2
Re: For Loop question
I have moved your thread from the VB.Net forums to the ASP.Net forums and also added code tags to your code. Code tags keep your code properly formatted and you can either manually type them like this:
[CODE]'Hello world![/CODE]
Or you can hit the pound(hash) sign in the quick or advanced reply and it will add them for you. Take look at the difference:
With Code Tags
Code:
If foo = True Then
Console.WriteLine("Foo")
Else
Console.WriteLine("Bar")
End If
Without Code Tags
If foo = True Then
Console.WriteLine("Foo")
Else
Console.WriteLine("Bar")
End If
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|