• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 168
  • Last Modified:

Radio button selection gives same results

I've created a group of radio button being used to select the correct answer of a question. I'm unsure why, but regardless of which one is selected, it always displays correct. Any suggestions?
~TIA
Private Sub btbOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btbOK.Click
        Timer1.Enabled = False
        Dim BoardForm As New frmQuestion
        If RB1.Tag = m_CorrectAnswer OrElse RB2.Tag = m_CorrectAnswer OrElse RB3.Tag = m_CorrectAnswer OrElse RB4.Tag = m_CorrectAnswer Then
            PlayerTotal = (m_sender * 200) + PlayerTotal
            MessageBox.Show("Correct!", "Correct", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        Else
            MessageBox.Show("Sorry", "Wrong", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        End If

Open in new window

0
98fatboyrider
Asked:
98fatboyrider
  • 2
1 Solution
 
jpaulinoCommented:
With this :
"If RB1.Tag = mm_CorrectAnswer OrElse RB2.Tag = m_CorrectAnswer OrElse RB3.Tag = m_CorrectAnswer OrElse RB4.Tag = m_CorrectAnswer Then"
If any one of the radio buttons = m_CorrectAnswer then you will have a correct answer.
 
If have to include in each one if the radiobutton is selected and the tag = m_CorrectAnswer
0
 
jpaulinoCommented:
Try this way instead:

        If (RB1.Checked AndAlso RB1.Tag = m_CorrectAnswer) OrElse (RB2.Checked AndAlso RB2.Tag = m_CorrectAnswer) OrElse (RB3.Checked AndAlso RB3.Tag = m_CorrectAnswer) OrElse (RB4.Checked AndAlso RB4.Tag = m_CorrectAnswer) Then
            PlayerTotal = (m_sender * 200) + PlayerTotal
            MessageBox.Show("Correct!", "Correct", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        Else
            MessageBox.Show("Sorry", "Wrong", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        End If

Open in new window

0
 
98fatboyriderAuthor Commented:
That was it. Thank you.
0

Featured Post

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now