Question in Radiobutton

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

41 Replies - 7163 Views - Last Post: 18 March 2012 - 03:50 AM Rate Topic: ***** 1 Votes

#1 xfri  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 03-March 12

Question in Radiobutton

Posted 03 March 2012 - 11:36 PM

1.I was trying to do a quiz random questionnaire that will know what score you did get.
2.I am using radiobutton to choose a answer then if done answering you need to click Next Button.
3.I really don't know what codes i need to put in the radiobutton that will determine answer is correct and how to add the right answer he did get.






Is This A Good Question/Topic? 0
  • +

Replies To: Question in Radiobutton

#2 nK0de  Icon User is offline

  • Catch me As Exception
  • member icon

Reputation: 205
  • View blog
  • Posts: 823
  • Joined: 21-December 11

Re: Question in Radiobutton

Posted 03 March 2012 - 11:38 PM

use IF ELSE statements to determine whether user has chosen the right answer.
Was This Post Helpful? 1
  • +
  • -

#3 xfri  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 03-March 12

Re: Question in Radiobutton

Posted 03 March 2012 - 11:44 PM

Pictures

Attached image(s)

  • Attached Image
  • Attached Image
  • Attached Image

Was This Post Helpful? 0
  • +
  • -

#4 nK0de  Icon User is offline

  • Catch me As Exception
  • member icon

Reputation: 205
  • View blog
  • Posts: 823
  • Joined: 21-December 11

Re: Question in Radiobutton

Posted 04 March 2012 - 12:08 AM

This is a VB.NET question. You're in the wrong forum. Don't worry, a mod will move it for you.
And instead of posting screenshots, its better to post your code here. Use the code tags.

And also I'll elaborate my answer in the previous post a little bit here.
To keep score, you must have a global variable. The easiest way to do that is create a Module and declare a variable there so that you can access it from anywhere within your program.

When a form's Next button is clicked, hide the current form, show the next form. In the meantime, use an If Else statement to evaluate the given answer in each form. If the correct Radiobutton is checked, increment the global variable by 1. Same scenario for all the forms and in the end, you only have to display that variable in a Label or Textbox or I dunno. There you have the final score.

This post has been edited by nK0de: 04 March 2012 - 12:11 AM

Was This Post Helpful? 1
  • +
  • -

#5 xfri  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 03-March 12

Re: Question in Radiobutton

Posted 04 March 2012 - 12:59 AM

Thank you for the reply, now i want to make my quiz's random question.
Was This Post Helpful? 0
  • +
  • -

#6 nK0de  Icon User is offline

  • Catch me As Exception
  • member icon

Reputation: 205
  • View blog
  • Posts: 823
  • Joined: 21-December 11

Re: Question in Radiobutton

Posted 04 March 2012 - 01:06 AM

what have you tried?
I think you can make use of the Random Class in VB.NET. Haven't really done something like that personally so can't be 100% sure but give it a whirl.
Was This Post Helpful? 0
  • +
  • -

#7 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3730
  • View blog
  • Posts: 6,017
  • Joined: 08-June 10

Re: Question in Radiobutton

Posted 04 March 2012 - 04:22 AM

* Moved to the VB.NET forum *
Was This Post Helpful? 0
  • +
  • -

#8 xfri  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 03-March 12

Re: Question in Radiobutton

Posted 04 March 2012 - 05:46 AM

I did try to answer the 3 quiz's, i purpose to get a wrong answer in MathQ1 and MathQ2 then i got the correct answer in MathQ3 but when the score show the dialog box said i got 2 correct answers.


Public Class MathQ1

    Private Sub TextBox1_TextChanged(sender As System.Object, e As System.EventArgs)

    End Sub

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Me.Hide()
        MathQ2.Show()
    End Sub

    Private Sub RadioButton1_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton1.CheckedChanged
        If Me.RadioButton1.Checked = True Then score += 1
    End Sub

    Private Sub RadioButton2_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton2.CheckedChanged
    End Sub

    Private Sub RadioButton3_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton3.CheckedChanged
    End Sub

    Private Sub RadioButton4_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton4.CheckedChanged
    End Sub
End Class


Public Class MathQ2

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Me.Hide()
        MathQ3.Show()

    End Sub

    Private Sub RadioButton1_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton1.CheckedChanged
    End Sub

    Private Sub RadioButton2_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton2.CheckedChanged
    End Sub

    Private Sub RadioButton3_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton3.CheckedChanged
        If Me.RadioButton3.Checked = True Then score += 1
    End Sub

    Private Sub RadioButton4_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton4.CheckedChanged
    End Sub
End Class


Public Class MathQ3

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Call MsgBox("Congratulations, your score is " & score, vbOKOnly Or vbInformation, "Score")
        Me.Hide()
        MathQ4.Show()
    End Sub

    Private Sub RadioButton1_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton1.CheckedChanged
    End Sub

    Private Sub RadioButton2_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton2.CheckedChanged
    End Sub

    Private Sub RadioButton3_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton3.CheckedChanged
        If Me.RadioButton3.Checked = True Then score += 1
    End Sub

    Private Sub RadioButton4_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton4.CheckedChanged
    End Sub
End Class

Was This Post Helpful? 0
  • +
  • -

#9 nK0de  Icon User is offline

  • Catch me As Exception
  • member icon

Reputation: 205
  • View blog
  • Posts: 823
  • Joined: 21-December 11

Re: Question in Radiobutton

Posted 04 March 2012 - 05:54 AM

you don't really have to put the If Else block in Radiobutton's event. You can put it inside the button click event. and only one If Else statement would be enough to evaluate the correct answer.

say, in Form1 the correct answer is Radiobutton1. So something simple like this would do,

    Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click

        Me.Hide()
        Form2.Show()

        If RadioButton1.Checked = True Then
            score += 1
        End If

    End Sub

This post has been edited by nK0de: 04 March 2012 - 05:55 AM

Was This Post Helpful? 1
  • +
  • -

#10 xfri  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 03-March 12

Re: Question in Radiobutton

Posted 04 March 2012 - 05:55 AM

Of course i did check the radiobuttons name and i choose the right answer but it still show i got 2 correct answer but it supposed to show in score i got 1 correct answer.
Was This Post Helpful? 0
  • +
  • -

#11 xfri  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 03-March 12

Re: Question in Radiobutton

Posted 04 March 2012 - 06:03 AM

Thank you again you are my savior in VB :smile2:
Was This Post Helpful? 0
  • +
  • -

#12 xfri  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 03-March 12

Re: Question in Radiobutton

Posted 04 March 2012 - 06:26 AM

I have another question i already got 20 correct answer now how i can average my score that the dialog box will say it too.

Public Class MathScore

    Private Sub MathScore_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Call MsgBox("Congratulations, your score is " & score, vbOKOnly Or vbInformation, "Score")
    End Sub
End Class

Was This Post Helpful? 0
  • +
  • -

#13 nK0de  Icon User is offline

  • Catch me As Exception
  • member icon

Reputation: 205
  • View blog
  • Posts: 823
  • Joined: 21-December 11

Re: Question in Radiobutton

Posted 04 March 2012 - 06:33 AM

Declare a variable to hold the result. Sum up the correct number of right answers (you already know how to get that now) and divide it by the number of questions given. In your case, as you say its 20. I suppose you know how to do simple calculation in VB.NET. Pretty simple.

This post has been edited by nK0de: 04 March 2012 - 06:36 AM

Was This Post Helpful? 1
  • +
  • -

#14 xfri  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 03-March 12

Re: Question in Radiobutton

Posted 04 March 2012 - 08:57 AM

I have another question i want to put a text speech in my questionnaire and how to make my questionnaire randomize?
Was This Post Helpful? 0
  • +
  • -

#15 nK0de  Icon User is offline

  • Catch me As Exception
  • member icon

Reputation: 205
  • View blog
  • Posts: 823
  • Joined: 21-December 11

Re: Question in Radiobutton

Posted 04 March 2012 - 09:13 AM

I haven't done anything like Text to speech in my work. You could take a look at this article and see for yourself. And here's another way.

There is a simple way to speak up what's in the .Text property of controls. Take a look at this video.

This post has been edited by nK0de: 04 March 2012 - 09:24 AM

Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3