Solved

Radio button selection gives same results

Posted on 2008-10-11
3
137 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

708 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

17 Experts available now in Live!

Get 1:1 Help Now