Results 1 to 2 of 2

Thread: For Loop question

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2011
    Posts
    58

    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.

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
  •  



Click Here to Expand Forum to Full Width