Problems with question case

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

32 Replies - 1057 Views - Last Post: 10 January 2012 - 10:40 AM Rate Topic: -----

#1 sheepboi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 02-January 12

Problems with question case

Posted 09 January 2012 - 07:13 AM

Hi, i've recently set up a form in which a question will be displayed and then have three possible answers in the form of radio buttons. My code states that one of these radio buttons (the correct answer) will add a value of 1, and the amount of correct answers selected will show a messagebox at the end. However, moving from question to question is proving harder than i thought, i know it's something really small iv'e overlooked and somebody will probably pick it up straight away. (i hope). Here is my code below, my problem is when i click my NEXT button, only the first question and answer sets populate, it will not move forward from question to question and so i will not be able to finish. Here is an example of two of the question and answer sets, only the first one will populate, it will not move forward if i click NEXT again.


  lblQuestion.Text = ("How do you change the font style on all slides in a presentation that already has a theme applied?")
        rbAnswer1.Text = ("Change the fonts on the slide master")
        rbAnswer2.Text = ("After selecting all slides, click Fonts from the Home tab. Then select the new font style(s)")
        rbAnswer3.Text = ("Go to the Design tab and click Fonts. Then select the new font style(s)")
        If NQUESTION = 2 And rbAnswer3.Checked = True Then
            NQUESTION = NQUESTION + 1



            lblQuestion.Text = ("For what reason would you use the Custom Animation item on the Animations tab?")
            rbAnswer1.Text = ("It is available for personal preference. Everything you can do from this command is available directly on the Ribbon")
            rbAnswer2.Text = ("It allows you to create more complex animations and transitions than you can get from the commands directly on the Ribbon")
            rbAnswer3.Text = ("There is no Custom Animation item on the Animations tab")

        ElseIf NQUESTION = 3 And rbAnswer2.Checked = True Then
            NQUESTION = NQUESTION + 1 


Is This A Good Question/Topic? 0
  • +

Replies To: Problems with question case

#2 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1752
  • View blog
  • Posts: 4,409
  • Joined: 14-March 10

Re: Problems with question case

Posted 09 January 2012 - 07:30 AM

Look the first question is out of any if condition, so probaably will be added every time, and you dont increase NQUESTION except inside if condition which the execution do not enter.....
I may have something like this:
'Declare NQUESTION outside the sub, like what you did and initialize to 1
If NQUESTION = 1 Then
   NQUESTION = NQUESTION + 1
   'populate question one
ElseIf NQUESTION = 2 Then
   NQUESTION = NQUESTION + 1
   'populate question two
'.....

End If


It didnt go to the next question because the first time NQUESTION = NQUESTION + 1 is not executed and so NQUESTION is not increasing to 2
Was This Post Helpful? 1
  • +
  • -

#3 sheepboi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 02-January 12

Re: Problems with question case

Posted 09 January 2012 - 07:55 AM

I have tried putting the question and answer information below but it wont populate as it needs to be above the NQUESTION statement, without having my radio button statements (And rbAnswer1.Checked = True Then) how will the program know which one is the correct answer? The first question always moves forward because on form load i have a START button which when clicked has the first question inside, and then from there the NEXT button in clicked to move forward (or in this case, not) Thanks for the previous support by the way!
Was This Post Helpful? 0
  • +
  • -

#4 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1752
  • View blog
  • Posts: 4,409
  • Joined: 14-March 10

Re: Problems with question case

Posted 09 January 2012 - 09:19 AM

Then if the first question is loaded on form load, you dont need to include it in next button anymore, what you can do is on form load, after loading the question, increase NQUESTION to 2 so you can start question two when button next clicked.

You are the one to tell the program what is the correct answer...

And please post the code which you have updated so we can see what you have done and how we can help...
Was This Post Helpful? 0
  • +
  • -

#5 sheepboi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 02-January 12

Re: Problems with question case

Posted 09 January 2012 - 09:46 AM

I have used the method you mentioned and it gets to the same stage, i cannot move any further forward than the first question in NEXT(there are a further 18), and i was wondering about how it would know the correct answer, because unlike the original version now the radio button statement is no longer there



lblQuestion.Text = ("How do you change the font style on all slides in a presentation that already has a theme applied?")
        rbAnswer1.Text = ("Change the fonts on the slide master")
        rbAnswer2.Text = ("After selecting all slides, click Fonts from the Home tab. Then select the new font style(s)")
        rbAnswer3.Text = ("Go to the Design tab and click Fonts. Then select the new font style(s)")
        If NQUESTION = 2 Then
            NQUESTION = NQUESTION + 1





            lblQuestion.Text = ("For what reason would you use the Custom Animation item on the Animations tab?")
            rbAnswer1.Text = ("It is available for personal preference. Everything you can do from this command is available directly on the Ribbon")
            rbAnswer2.Text = ("It allows you to create more complex animations and transitions than you can get from the commands directly on the Ribbon")
            rbAnswer3.Text = ("There is no Custom Animation item on the Animations tab")
        ElseIf NQUESTION = 3 Then
            NQUESTION = NQUESTION + 1

Was This Post Helpful? 0
  • +
  • -

#6 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1752
  • View blog
  • Posts: 4,409
  • Joined: 14-March 10

Re: Problems with question case

Posted 09 January 2012 - 09:56 AM

No, I didnt tell you to remove the radioButton case but I was just showing you the logic:
If NQUESTION = 2 And rbAnswer3.Checked = True Then

The problem is why you put question one again here?

Look at my design above, I remove the code which was outside the if condition and you return it again!
Also show us the load form event, I told you to put this line there:
NQUESTION = NQUESTION + 1


As I see you have done the same thing which I have changed above, the idea of my changes above is to remove the first question code which was outside the if condition
Was This Post Helpful? 0
  • +
  • -

#7 sheepboi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 02-January 12

Re: Problems with question case

Posted 09 January 2012 - 10:15 AM

Here is my START button which brings up the first question:

 If NQUESTION = 1 And rbAnswer2.Checked = True Then
            NQUESTION = NQUESTION + 1
            lblQuestion.Text = ("To add a new slide that may have text or graphics or both, which slide layout should you choose?")
            rbAnswer1.Text = ("Title only")
            rbAnswer2.Text = ("Title and Content")
            rbAnswer3.Text = ("Title and Text")


Here is my form load:
Private Sub frmLoad()

        NQUESTION = NQUESTION + 1


And my other two questions which i have been posting are in the NEXT button which appears when start is clicked. It controls the move forward of questions but only the first question will be shown:
If NQUESTION = 2 And rbAnswer1.Checked = True Then
            NQUESTION = NQUESTION + 1
            lblQuestion.Text = ("How do you change the font style on all slides in a presentation that already has a theme applied?")
            rbAnswer1.Text = ("Change the fonts on the slide master")
            rbAnswer2.Text = ("After selecting all slides, click Fonts from the Home tab. Then select the new font style(s)")
            rbAnswer3.Text = ("Go to the Design tab and click Fonts. Then select the new font style(s)")




        ElseIf NQUESTION = 3 And rbAnswer3.Checked = True Then
            NQUESTION = NQUESTION + 1
            lblQuestion.Text = ("For what reason would you use the Custom Animation item on the Animations tab?")
            rbAnswer1.Text = ("It is available for personal preference. Everything you can do from this command is available directly on the Ribbon")
            rbAnswer2.Text = ("It allows you to create more complex animations and transitions than you can get from the commands directly on the Ribbon")
            rbAnswer3.Text = ("There is no Custom Animation item on the Animations tab")

Was This Post Helpful? 0
  • +
  • -

#8 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1752
  • View blog
  • Posts: 4,409
  • Joined: 14-March 10

Re: Problems with question case

Posted 09 January 2012 - 10:34 AM

Private Sub frmLoad()

This load event sub is not complete as per VB.Net, you need to give the complete signature, like:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


Also I wonder if your button click event is even correct, can we see the complete button click event from its start t end. A complete one must have identified which handles it looks for:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Was This Post Helpful? 0
  • +
  • -

#9 sheepboi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 02-January 12

Re: Problems with question case

Posted 09 January 2012 - 10:47 AM

i've noticed i dont really have to put my first question in form load as it populates with it being in the START as well. My START button click event is as follows:
Private Sub cmdStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdStart.Click


        lblQuestion.Text = ("To add a new slide that may have text or graphics or both, which slide layout should you choose?")
        rbAnswer1.Text = ("Title only")
        rbAnswer2.Text = ("Title and Content")
        rbAnswer3.Text = ("Title and Text")
        If NQUESTION = 1 And rbAnswer2.Checked = True Then
            NQUESTION = NQUESTION + 1


then i use the NEXT button to move forward, the click event for this is:

Private Sub cmdNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdNext.Click
Was This Post Helpful? 0
  • +
  • -

#10 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1752
  • View blog
  • Posts: 4,409
  • Joined: 14-March 10

Re: Problems with question case

Posted 09 January 2012 - 11:00 AM

I assume NQUESTION is initially zero when the first question loads, then this statement will be false and so the variable wont increment:
        If NQUESTION = 1 And rbAnswer2.Checked = True Then
	            NQUESTION = NQUESTION + 1


Also rbAnswer2.Checked = True is false because at the time Start button clicks, nothing has been checked yet!!!!

That means:
- You dont need the above mentioned condition since it is useless since it will always be false!
- Initialize your NQUESTION to 1, because you need it to be 2 to load the second question
- Your Start sub will be as :
Private Sub cmdStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdStart.Click


        lblQuestion.Text = ("To add a new slide that may have text or graphics or both, which slide layout should you choose?")
        rbAnswer1.Text = ("Title only")
        rbAnswer2.Text = ("Title and Content")
        rbAnswer3.Text = ("Title and Text")
        NQUESTION = NQUESTION + 1
End Sub


After doing those three changes, when form loads, NQUESTION will be 1, and after Start button click it will be 2, and so when you click Next button the condition to load question two will true and so you can load it...
Was This Post Helpful? 1
  • +
  • -

#11 sheepboi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 02-January 12

Re: Problems with question case

Posted 09 January 2012 - 11:53 AM

Just a quick update, im working on those changes and ive so far changed the values so that it starts from 0, and it loops through all the questions which is great, but it only moves onto the next one if the question is answered correctly, which i think has something to do with my radio button line of code
Was This Post Helpful? 0
  • +
  • -

#12 sheepboi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 02-January 12

Re: Problems with question case

Posted 09 January 2012 - 12:10 PM

My form now loops through all of the questions and my last remaining problem is totalling the score, as it will not notice the correct answer now and was wondering how i could do it and get it to add up the correct answers as the user loops through the questions. Here is my code for how i am going to show and add my score up:
'scores the question in a percentage by multiplying by 100 then dividing that by 20
        score = CQUESTION * 100 / 20

        'the score textbox will give the score figure plus the percentage sign
        lblScore.Text() = Str(score) & "%"

    End Sub
    Private Sub level()

        'declaring the select case
        Select Case CQUESTION
            'a score of 0 to 8 will advice a beginner coourse
            Case 0 To 8
                lblLevel.Text = "You should take the begginer course"
                'a score of 8 to 15 will advice of an intermediate course
            Case 8 To 15
                lblLevel.Text = "You should take the intermediate course"
                'a score of 16 to 20 will advice of an advanced course
            Case 16 To 20
                lblLevel.Text = "You should take the advanced course"

Was This Post Helpful? 0
  • +
  • -

#13 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1752
  • View blog
  • Posts: 4,409
  • Joined: 14-March 10

Re: Problems with question case

Posted 09 January 2012 - 12:10 PM

Yap, it only goes to the next question if the previous question is correct, and I thought that is the one which you need here:
If NQUESTION = 2 And rbAnswer1.Checked = True Then ' you make it to check which radio button has been selected before showing next question!


If you not that behavior you can remove that condition on next operation and do another way to check for the correct answer.
For example:
- You can put a separate if statement that can take care of the selected button and adding marks
- This if condition will be before loading another question, checking the right question, adding marks and if the wrong answer you can decide either to give user another chance or else
Was This Post Helpful? 1
  • +
  • -

#14 kikurt  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 24-September 09

Re: Problems with question case

Posted 09 January 2012 - 12:16 PM

View Postsheepboi, on 09 January 2012 - 07:13 AM, said:

Hi, i've recently set up a form in which a question will be displayed and then have three possible answers in the form of radio buttons. My code states that one of these radio buttons (the correct answer) will add a value of 1, and the amount of correct answers selected will show a messagebox at the end. However, moving from question to question is proving harder than i thought, i know it's something really small iv'e overlooked and somebody will probably pick it up straight away. (i hope). Here is my code below, my problem is when i click my NEXT button, only the first question and answer sets populate, it will not move forward from question to question and so i will not be able to finish. Here is an example of two of the question and answer sets, only the first one will populate, it will not move forward if i click NEXT again.


  lblQuestion.Text = ("How do you change the font style on all slides in a presentation that already has a theme applied?")
        rbAnswer1.Text = ("Change the fonts on the slide master")
        rbAnswer2.Text = ("After selecting all slides, click Fonts from the Home tab. Then select the new font style(s)")
        rbAnswer3.Text = ("Go to the Design tab and click Fonts. Then select the new font style(s)")
        If NQUESTION = 2 And rbAnswer3.Checked = True Then
            NQUESTION = NQUESTION + 1



            lblQuestion.Text = ("For what reason would you use the Custom Animation item on the Animations tab?")
            rbAnswer1.Text = ("It is available for personal preference. Everything you can do from this command is available directly on the Ribbon")
            rbAnswer2.Text = ("It allows you to create more complex animations and transitions than you can get from the commands directly on the Ribbon")
            rbAnswer3.Text = ("There is no Custom Animation item on the Animations tab")

        ElseIf NQUESTION = 3 And rbAnswer2.Checked = True Then
            NQUESTION = NQUESTION + 1 


hello.. we have the same problem bro. my main problem is how to count the number of correct or wrong answer in all the questions that i have and how to make a results with the number of correct and wrong answer in my database. i hope somebody can help us.
Was This Post Helpful? 0
  • +
  • -

#15 sheepboi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 02-January 12

Re: Problems with question case

Posted 09 January 2012 - 12:17 PM

Ahh i see where i have caused the confusion (not to say the help wasnt useful as it really was!) But my goal was to design a questionnaire and users would have to select one of three possible answers and when the user presses NEXT the question would move forward (whether or not the response is correct) Then when the last question is complete a messagebox appears to tell them the score, However all i need now is a way to add the scores but i dont know how i could change my previous radio button statement to suit my purpose.
Was This Post Helpful? 0
  • +
  • -

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