Solved

Radio button selection gives same results

Posted on 2008-10-11
3
138 Views
Last Modified: 2012-05-05
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
Comment
Question by:98fatboyrider
  • 2
3 Comments
 
LVL 48

Expert Comment

by:jpaulino
ID: 22695736
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
 
LVL 48

Accepted Solution

by:
jpaulino earned 500 total points
ID: 22695750
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
 

Author Closing Comment

by:98fatboyrider
ID: 31505376
That was it. Thank you.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now