Results 1 to 18 of 18

Thread: Correct / Incorrect

  1. #1

    Thread Starter
    Member
    Join Date
    May 2011
    Posts
    42

    Correct / Incorrect

    Been working through a maths game and have got so far but face my problem with the answers, no matter what input i put in ( numbers ofc ) it says there correct, i cant work out why its not doing what i coded it to do, if you can notice whats wrong your a star.

    Math game Code:
    1. Public Class Form3
    2.  
    3.     Dim RandomClass As New Random
    4.     Dim symbole As Integer
    5.     Dim Answers As Integer
    6.     Public Wrong_Answer As Integer
    7.     Public Total_Correct As Integer
    8.     Public Lifes As Integer
    9.  
    10.  
    11.  
    12.  
    13.  
    14.  
    15.  
    16.  
    17.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    18.  
    19.         check()
    20.  
    21.     End Sub
    22.     Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    23.  
    24.         lblname.Text = username
    25.         randomize()
    26.  
    27.     End Sub
    28.     Sub randomize()
    29.  
    30.  
    31.         Int(Rnd() * 25)
    32.         TextBox1.Text = ""
    33.         textbox2.Text = (RandomClass.Next(1, 10))
    34.         textbox3.Text = (RandomClass.Next(1, 10))
    35.         symbole = CInt(Int(Rnd() * 4) + 1)
    36.  
    37.         If symbole = 1 Then label2.Text = ("+")
    38.         If symbole = 2 Then label2.Text = ("-")
    39.         If symbole = 3 Then label2.Text = ("*")
    40.         If symbole = 4 Then label2.Text = ("/")
    41.  
    42.  
    43.     End Sub
    44.     Sub check()
    45.         If symbole = 1 Then check1()
    46.         If symbole = 2 Then check2()
    47.         If symbole = 3 Then check3()
    48.         If symbole = 4 Then check4()
    49.     End Sub
    50.  
    51.     Sub Check1()
    52.  
    53.  
    54.         Dim variable1 As Double
    55.         Double.TryParse(TextBox1.Text, variable1)
    56.  
    57.         Dim variable2 As Double
    58.         Double.TryParse(textbox2.Text, variable2)
    59.  
    60.         Dim answers As Double = variable1 + variable2
    61.  
    62.         If variable1 + variable2 = answers Then
    63.             Msgboxcor()
    64.  
    65.         Else
    66.             If variable1 + variable2 <> answers Then Msgboxinc()
    67.  
    68.  
    69.  
    70.         End If
    71.  
    72.  
    73.  
    74.     End Sub
    75.  
    76.     Sub check2()
    77.  
    78.             Dim variable1 As Double
    79.             Double.TryParse(TextBox1.Text, variable1)
    80.  
    81.             Dim variable2 As Double
    82.             Double.TryParse(textbox2.Text, variable2)
    83.  
    84.             Dim answers As Double = variable1 - variable2
    85.  
    86.             If variable1 - variable2 = answers Then
    87.                 Msgboxcor()
    88.  
    89.             Else
    90.                 Msgboxinc()
    91.  
    92.  
    93.             End If
    94.  
    95.  
    96.     End Sub
    97.  
    98.     Sub check3()
    99.  
    100.             Dim variable1 As Double
    101.             Double.TryParse(TextBox1.Text, variable1)
    102.  
    103.             Dim variable2 As Double
    104.             Double.TryParse(textbox2.Text, variable2)
    105.  
    106.             Dim answers As Double = variable1 * variable2
    107.  
    108.             If variable1 * variable2 = answers Then
    109.                 Msgboxcor()
    110.  
    111.             Else
    112.                 Msgboxinc()
    113.  
    114.  
    115.             End If
    116.  
    117.  
    118.     End Sub
    119.  
    120.     Sub check4()
    121.  
    122.             Dim variable1 As Double
    123.             Double.TryParse(TextBox1.Text, variable1)
    124.  
    125.             Dim variable2 As Double
    126.             Double.TryParse(textbox2.Text, variable2)
    127.  
    128.             Dim answers As Double = variable1 * variable2
    129.  
    130.             If variable1 * variable2 = answers Then
    131.                 Msgboxcor()
    132.  
    133.             Else
    134.                 Msgboxinc()
    135.  
    136.  
    137.             End If
    138.  
    139.  
    140.     End Sub
    141.  
    142.     Sub Msgboxcor()
    143.  
    144.  
    145.             MsgBox("Correct")
    146.  
    147.             Total_Correct = +1
    148.  
    149.             randomize()
    150.  
    151.     End Sub
    152.  
    153.     Sub Msgboxinc()
    154.  
    155.             MsgBox("Incorrect")
    156.  
    157.             Wrong_Answer = +1
    158.             Lifes = +1
    159.  
    160.             If Lifes = 2 Then Close()
    161.  
    162.  
    163.     End Sub
    164.  
    165.  
    166.  
    167. End Class

  2. #2
    Hyperactive Member
    Join Date
    Oct 2010
    Location
    Indiana
    Posts
    457

    Re: Correct / Incorrect

    Not completely sure what you are trying to do with this program, but...

    vb Code:
    1. Dim answers As Double = variable1 + variable2
    2.         If variable1 + variable2 = answers Then
    3.             Msgboxcor()
    4.         Else
    5.             If variable1 + variable2 <> answers Then Msgboxinc()
    6.         End If
    You just set you "answers" variable = variable1 + variable2, then compaire if it is equal to variable1 + variable2...
    Of course it is going to say it is true.
    Thats like saying:
    vb Code:
    1. Answer = 1
    2. If 1 = Answer then

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: Correct / Incorrect

    You are declaring Answers at class scope (outside of all methods), then you are declaring a different variable of the same name inside your Check methods. That's not good. What nO One stated is entirely correct, but why do you even have the Answers variable at class scope?

    There are other points, though they don't directly relate to the problem.

    1) You are using a Random object called RandomClass. That's good. However, you are also using the old VB6 style Rnd() method, which is totally bizarre. Get rid of the Rnd calls, the lines that are using that should be using your RandomClass object. There certainly isn't any advantage to Rnd. It is harder to use, harder to read, and requires other things that you won't be able to do (such as calling the Randomize function, which will be tricky since you have a function with that name in the class, so you would have to decorate the call to the other Randomize, but without that call, Rnd will behave poorly).

    2) You have this:
    Code:
    Wrong_Answer = +1
    Lifes = +1
    
    If Lifes = 2 Then Close()
    What you meant to write is:
    Code:
    Wrong_Answer += 1
    Lifes += 1
    
    If Lifes = 2 Then Close()
    The way you have it, Lifes will just be set to 1, so the If statement will never be True, because Lifes will always be 1 and never anything else.

    3) You clearly don't have Option Strict ON, or else parts of that code wouldn't compile, but you are doing a pretty good job of explicitly converting strings to variables already, so you should just turn Option Strict ON and fix the few errors remaining. Option Strict makes for faster code, and forces you to learn some good habits that you are mostly doing already (your use of Double.TryParse shows that).

    4) One quibble about your use of Double.Tryparse is that it will return False if the string can't be converted to a number. Since you aren't checking the return value, if the user enters garbage into the two textboxes, then both variable1 and variable2 will hold 0. That might be ok, though it is likely to result in the wrong answer, and in some cases, it could lead to incorrectly showing the right answer. There is a worse problem with that if you used division, since you would be dividing by 0, but see item 5.

    5) You have four different operations: +, -, *, and /. You also have four 'check' methods. The first three use +, -, and *, so I would expect that check4 would use /, but it just uses * a second time. I would guess that that one is incorrect.
    My usual boring signature: Nothing

  4. #4

    Thread Starter
    Member
    Join Date
    May 2011
    Posts
    42

    Re: Correct / Incorrect

    Thanks for pointing out the mistakes i made with the Divide didn't notice that. and i have changed the counters to +=1, also put strict on and have now got no errors with strict.

    what am i changing rnd to ? RandomClass object, would i replace all rnd's with ( RandomClass.next ) ?
    something like this ? i know im not doing it right because when i launch the program no random questions appere, but im putting it up to show you what im doing because i dont know what im to put in its place :P but helps is i put it up so you can see.

    vb Code:
    1. Int(RandomClass.Next() * 25)
    2.         TextBox1.Text = ""
    3.         textbox2.Text = CStr((RandomClass.Next(1, 10)))
    4.         textbox3.Text = CStr((RandomClass.Next(1, 10)))
    5.         symbole = CInt(Int(RandomClass.Next() * 4) + 1)


    also im a little confused what im doing with try.parse, what do i have to change so i can check the returned value, so its ether right or wrong ? sorry if im becoming a pain :P most of this is new to me.

    Thanks for your cooperation and patience

    vb Code:
    1. Public Class Form3
    2.  
    3.     Dim RandomClass As New Random
    4.     Dim symbole As Integer
    5.     Dim Answers As Integer
    6.     Public Wrong_Answer As Integer
    7.     Public Total_Correct As Integer
    8.     Public Lifes As Integer
    9.  
    10.  
    11.  
    12.  
    13.  
    14.  
    15.  
    16.  
    17.  
    18.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    19.  
    20.         check()
    21.  
    22.     End Sub
    23.     Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    24.  
    25.         lblname.Text = username
    26.         randomize()
    27.  
    28.     End Sub
    29.     Sub randomize()
    30.  
    31.  
    32.         Int(Rnd() * 25)
    33.         TextBox1.Text = ""
    34.         textbox2.Text = CStr((RandomClass.Next(1, 10)))
    35.         textbox3.Text = CStr((RandomClass.Next(1, 10)))
    36.         symbole = CInt(Int(Rnd() * 4) + 1)
    37.  
    38.         If symbole = 1 Then label2.Text = ("+")
    39.         If symbole = 2 Then label2.Text = ("-")
    40.         If symbole = 3 Then label2.Text = ("*")
    41.         If symbole = 4 Then label2.Text = ("/")
    42.  
    43.  
    44.     End Sub
    45.     Sub check()
    46.         If symbole = 1 Then Check1()
    47.         If symbole = 2 Then check2()
    48.         If symbole = 3 Then check3()
    49.         If symbole = 4 Then check4()
    50.     End Sub
    51.  
    52.     Sub Check1()
    53.  
    54.  
    55.         Dim variable1 As Double
    56.         Double.TryParse(textbox2.Text, variable1)
    57.  
    58.         Dim variable2 As Double
    59.         Double.TryParse(textbox3.Text, variable2)
    60.  
    61.         Dim answers As Double = variable1 + variable2
    62.  
    63.         If Double.TryParse(TextBox1.Text, answers) Then
    64.             Msgboxcor()
    65.  
    66.         Else
    67.             If variable1 + variable2 <> answers Or False Then Msgboxinc()
    68.  
    69.  
    70.  
    71.         End If
    72.  
    73.  
    74.  
    75.     End Sub
    76.  
    77.     Sub check2()
    78.  
    79.         Dim variable1 As Double
    80.         Double.TryParse(textbox2.Text, variable1)
    81.  
    82.         Dim variable2 As Double
    83.         Double.TryParse(textbox3.Text, variable2)
    84.  
    85.         Dim answers As Double = variable1 - variable2
    86.  
    87.         If variable1 - variable2 = answers Then
    88.             Msgboxcor()
    89.  
    90.         Else
    91.             Msgboxinc()
    92.  
    93.  
    94.         End If
    95.  
    96.  
    97.     End Sub
    98.  
    99.     Sub check3()
    100.  
    101.         Dim variable1 As Double
    102.         Double.TryParse(textbox2.Text, variable1)
    103.  
    104.         Dim variable2 As Double
    105.         Double.TryParse(textbox3.Text, variable2)
    106.  
    107.         Dim answers As Double = variable1 * variable2
    108.  
    109.         If variable1 * variable2 = answers Then
    110.             Msgboxcor()
    111.  
    112.         Else
    113.             Msgboxinc()
    114.  
    115.  
    116.         End If
    117.  
    118.  
    119.     End Sub
    120.  
    121.     Sub check4()
    122.  
    123.         Dim variable1 As Double
    124.         Double.TryParse(textbox2.Text, variable1)
    125.  
    126.         Dim variable2 As Double
    127.         Double.TryParse(textbox3.Text, variable2)
    128.  
    129.         Dim answers As Double = variable1 / variable2
    130.  
    131.         If variable1 / variable2 = answers Then
    132.             Msgboxcor()
    133.  
    134.         Else
    135.             Msgboxinc()
    136.  
    137.  
    138.         End If
    139.  
    140.  
    141.     End Sub
    142.  
    143.     Sub Msgboxcor()
    144.  
    145.  
    146.         MsgBox("Correct")
    147.  
    148.         Total_Correct += 1
    149.  
    150.         randomize()
    151.  
    152.     End Sub
    153.  
    154.     Sub Msgboxinc()
    155.  
    156.         MsgBox("Incorrect")
    157.  
    158.         Wrong_Answer += 1
    159.         Lifes += 1
    160.  
    161.         If Lifes = 2 Then Close()
    162.  
    163.  
    164.     End Sub
    165.  
    166.  
    167.  
    168. End Class

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: Correct / Incorrect

    Rnd() produced a floating point value that you had to manipulate to get it into the range you wanted to work with, then convert it into an integer. That's what all the *x + n stuff was about when you used Rnd(). The Random object is superior to that, because you just tell it the range you want as arguments to the Next method:

    For values from 0 through 25:

    value = RandomClass.Next(26)

    For values from 5 through 25:

    value = RandomClass.Next(5,26)

    Note that the lower value is included in the range, but the upper value is one higher than the range that you want. Also note that if the bottom of the range is 0, you don't even need to mention it, and only the upper bound is needed. Furthermore, since .Next returns an Integer, you don't have to convert it into an integer with CInt, because it already IS an integer.


    As for the Double.TryParse, there are many ways you could work with this. The question you need to decide is what you want to do if the entry in the textbox is NOT a number, which means that it contains non-numeric characters, or was left empty. What you want to do in that case will determine the best solution for you. One option would look like this:
    Code:
    If Not Double.TryParse(TextBox1.Text, variable1) Then
     Windows.Forms.MessageBox.Show("You didn't enter a number!","Invalid Number")
     Return
    End If
    Doing something like that for each of your TryParse statements would mean that if the user clicked that button without entering valid numbers in the boxes, they would get a message, then nothing more would happen. That's the simplest possible solution. Of course, it would be better if the message indicated which textbox had bad information.

    Written this way, if there was something bad in the first textbox, the second textbox wouldn't even be examined. A much more complicated alternative would be to check each textbox, noting any problems with either one, and if either had a problem, then show those problems. This would allow the user to see ALL problems at once, rather than going through each one in turn. That's probably excessive for this program, but when you are validating MANY different inputs where the user could have made many different types of errors, then it would make more sense.

    Other people would take issue with my use of Return. There is a school of thought, to which I do not subscribe fully, that believes that all functions should have only one return point. If you believe that way, you could change the code such that it looked like this:
    Code:
    If Double.TryParse(Textbox1.Text,variable1) Then
     If Double.TryParse(Textbox2.Text,variable2) Then
      'All is well, the rest of your method goes here.
     Else
      'The second variable is bad, put up a message.
     End If
    Else
     'The first variable is bad, put up a message.
    End If
    So there are options, as you can see.
    My usual boring signature: Nothing

  6. #6

    Thread Starter
    Member
    Join Date
    May 2011
    Posts
    42

    Re: Correct / Incorrect

    thanks shaggy hiker for your help.
    have made the following changes you pointed out, codes getting messy now but im sure it does that no matter what you do :P

    iv made all the corrections but still after entering a correct answer it 1st pops up saying correct and then straight after it pops up the incorrect msgbox too. il put my code back up, sorry for all the hassle.

    vb Code:
    1. Public Class Form3
    2.  
    3.     Dim RandomClass As New Random
    4.     Dim symbole As Integer
    5.     Dim Answers As Integer
    6.     Public Wrong_Answer As Integer
    7.     Public Total_Correct As Integer
    8.     Public Lifes As Integer
    9.  
    10.  
    11.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    12.  
    13.         check()
    14.  
    15.     End Sub
    16.     Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    17.  
    18.         lblname.Text = username
    19.         randomize()
    20.         lblcorrect.Text = CStr(Total_Correct)
    21.         lblwrong.Text = CStr(Wrong_Answer)
    22.         lbllife.Text = CStr(Lifes)
    23.        
    24.     End Sub
    25.     Sub randomize()
    26.  
    27.  
    28.         RandomClass.Next(0, 26)
    29.         TextBox1.Text = ""
    30.         textbox2.Text = CStr(RandomClass.Next(1, 10))
    31.         textbox3.Text = CStr(RandomClass.Next(1, 10))
    32.         symbole = RandomClass.Next(1, 4)
    33.  
    34.         If symbole = 1 Then label2.Text = ("+")
    35.         If symbole = 2 Then label2.Text = ("-")
    36.         If symbole = 3 Then label2.Text = ("*")
    37.         If symbole = 4 Then label2.Text = ("/")
    38.  
    39.  
    40.     End Sub
    41.     Sub check()
    42.         If symbole = 1 Then Check1()
    43.         If symbole = 2 Then check2()
    44.         If symbole = 3 Then check3()
    45.         If symbole = 4 Then check4()
    46.     End Sub
    47.  
    48.     Sub Check1()
    49.  
    50.      
    51.  
    52.         Dim variable1 As Double
    53.         Double.TryParse(textbox2.Text, variable1)
    54.  
    55.         Dim variable2 As Double
    56.         Double.TryParse(textbox3.Text, variable2)
    57.  
    58.         Answers = CInt(variable1 + variable2)
    59.  
    60.         Dim Userinput As Double
    61.         Double.TryParse(TextBox1.Text, Userinput)
    62.  
    63.         If Not Double.TryParse(TextBox1.Text, variable1) Then
    64.             Windows.Forms.MessageBox.Show("Please Enter an answer to the question!", "Invalid Number")
    65.             Return
    66.         End If
    67.  
    68.         If Userinput = Answers Then
    69.             Msgboxcor()
    70.  
    71.  
    72.  
    73.         Else
    74.             Msgboxinc()
    75.  
    76.  
    77.  
    78.         End If
    79.  
    80.  
    81.  
    82.  
    83.     End Sub
    84.  
    85.     Sub check2()
    86.  
    87.         Dim variable1 As Double
    88.         Double.TryParse(textbox2.Text, variable1)
    89.  
    90.         Dim variable2 As Double
    91.         Double.TryParse(textbox3.Text, variable2)
    92.  
    93.         Dim answers As Double = variable1 - variable2
    94.  
    95.         answers = CInt(variable1 - variable2)
    96.  
    97.         Dim Userinput As Double
    98.         Double.TryParse(TextBox1.Text, Userinput)
    99.  
    100.         If Not Double.TryParse(TextBox1.Text, variable1) Then
    101.             Windows.Forms.MessageBox.Show("Please Enter an answer to the question!", "Invalid Number")
    102.             Return
    103.         End If
    104.  
    105.         If Userinput = answers Then
    106.  
    107.             Msgboxcor()
    108.  
    109.         Else
    110.  
    111.             Msgboxinc()
    112.  
    113.  
    114.         End If
    115.  
    116.  
    117.  
    118.  
    119.     End Sub
    120.  
    121.     Sub check3()
    122.  
    123.         Dim variable1 As Double
    124.         Double.TryParse(textbox2.Text, variable1)
    125.  
    126.         Dim variable2 As Double
    127.         Double.TryParse(textbox3.Text, variable2)
    128.  
    129.         Answers = CInt(variable1 * variable2)
    130.  
    131.         Dim Userinput As Double
    132.         Double.TryParse(TextBox1.Text, Userinput)
    133.  
    134.         If Not Double.TryParse(TextBox1.Text, variable1) Then
    135.             Windows.Forms.MessageBox.Show("Please Enter an answer to the question!", "Invalid Number")
    136.             Return
    137.         End If
    138.  
    139.         If Userinput = Answers Then
    140.             Msgboxcor()
    141.  
    142.         Else
    143.             Msgboxinc()
    144.  
    145.  
    146.         End If
    147.  
    148.        
    149.  
    150.  
    151.     End Sub
    152.  
    153.     Sub check4()
    154.  
    155.         Dim variable1 As Double
    156.         Double.TryParse(textbox2.Text, variable1)
    157.  
    158.         Dim variable2 As Double
    159.         Double.TryParse(textbox3.Text, variable2)
    160.  
    161.         Answers = CInt(variable1 / variable2)
    162.  
    163.         Dim Userinput As Double
    164.         Double.TryParse(TextBox1.Text, Userinput)
    165.  
    166.         If Not Double.TryParse(TextBox1.Text, variable1) Then
    167.             Windows.Forms.MessageBox.Show("Please Enter an answer to the question!", "Invalid Number")
    168.             Return
    169.         End If
    170.  
    171.         If Userinput = Answers Then
    172.             Msgboxcor()
    173.  
    174.         Else
    175.             Msgboxinc()
    176.         End If
    177.  
    178.        
    179.  
    180.  
    181.     End Sub
    182.  
    183.     Sub Msgboxcor()
    184.  
    185.  
    186.         MsgBox("Correct")
    187.  
    188.         Total_Correct += 1
    189.         Lifes = 0
    190.  
    191.         randomize()
    192.  
    193.     End Sub
    194.  
    195.     Sub Msgboxinc()
    196.  
    197.         MsgBox("Incorrect")
    198.  
    199.         Wrong_Answer += 1
    200.         Lifes += 1
    201.  
    202.         If Lifes = 2 Then Close()
    203.  
    204.  
    205.     End Sub
    206.  
    207.  
    208.    
    209. End Class

  7. #7
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: Correct / Incorrect

    Time to do a bit of debugging. Put a breakpoint on the call to check(), then step through the code. Something odd is happening if you are following both branches of the If statement, but I'm not seeing it. Stepping through the code will show it.
    My usual boring signature: Nothing

  8. #8
    Hyperactive Member
    Join Date
    Oct 2010
    Location
    Indiana
    Posts
    457

    Re: Correct / Incorrect

    vb Code:
    1. Sub Msgboxcor()
    2.     MsgBox("Correct")
    3.     Total_Correct += 1
    4.     Lifes = 0
    5.     randomize()
    6. End Sub
    Maybe it's becuase you are calling your randomize sub from within your msgboxcor sub. That is weird because it shouldn't re-evaluate the variables within the Check sub.

    Try taking out the randomize() from you msgboxcor sub (you don't have it in the msgboxinc sub) and see if that works.
    If that is the problem, but you want to keep it there, then setup your If statement so that it ends the Check sub after it runs the msgboxcor sub, that way it doesn't evaluate the other portion of the If statement.

  9. #9

    Thread Starter
    Member
    Join Date
    May 2011
    Posts
    42

    Re: Correct / Incorrect

    if i take it out and answer a question correctly it wont go back to randomize - it wont put a new question up, the reason i dont have it in msgboxinc sub is because if they get it wrong it leaves the save question on until they get it right but if they get it wrong 2 times the game ends.

    if i take it out of the msgboxcor sub then what do i use so it puts a new random question after its answered correctly ?

  10. #10
    Hyperactive Member
    Join Date
    Oct 2010
    Location
    Indiana
    Posts
    457

    Re: Correct / Incorrect

    I realized that after I posted it.
    If it didn't give you both msgs when you took it out, the I would reverse your if statement, evaluate if it is incorrect first, then check if it is correct

  11. #11

    Thread Starter
    Member
    Join Date
    May 2011
    Posts
    42

    Re: Correct / Incorrect

    Yeah taking the randomize() out i dont appere to get any of the wrong messages. so i should start by evaluating whether its wrong first, by that would you of put >>
    vb Code:
    1. If Userinput <> Answers Then Msgboxinc()
    2.         else
    3.         Msgboxcor()
    4.         End if

    if i do that the whole of my code on form3 has the blue line under everything. so im not sure what to do in place of <> answers.

  12. #12
    Hyperactive Member
    Join Date
    Oct 2010
    Location
    Indiana
    Posts
    457

    Re: Correct / Incorrect

    I am on my phone right now, so I can't test,
    But you an try it like:
    Code:
    If not userinput = answer then
    Last edited by nO_OnE; May 28th, 2011 at 05:03 PM.

  13. #13

    Thread Starter
    Member
    Join Date
    May 2011
    Posts
    42

    Re: Correct / Incorrect

    right that goes in without the blue lines but i still get both correct and incorrect msg box pop up occasinaly. from going through brakepoint at the check sub, that appears to be where its making the problem, running through it step by step it goes to one check says correct then press f10 then the message pops up because it goes to a new check if that makes sence. kinda hard to explain xD

    im in no rush so dont worry :P

  14. #14
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: Correct / Incorrect

    Don't use F10, that will hide the problem. You are going about it the right way, but the solution is not going to be what you expect. Using F11 will step you through each line, including each sub. That should show you something unusual.
    My usual boring signature: Nothing

  15. #15

    Thread Starter
    Member
    Join Date
    May 2011
    Posts
    42

    Re: Correct / Incorrect

    going through with F11 has shown me what is making it do it.

    it appears to be that some times after answering a question then it goes back to randomizing a new one then skips the part where a user enters an answer and goes straight to saying that no answer was input / incorrect, it dosent go to the stage where it allows the user to input the answer.

  16. #16
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: Correct / Incorrect

    I'm not sure what you mean by that, but I just noticed that you are getting a random number with the line .Next(1,4)

    The 4 is one above the maximum value, so that will return the values 1-3, whereas you want the values 1-4, so that should be .Next(1,5)
    My usual boring signature: Nothing

  17. #17

    Thread Starter
    Member
    Join Date
    May 2011
    Posts
    42

    Re: Correct / Incorrect

    i did not notice i had put 4, thanks for pointing that out. what i will do is make a video of what happens going through the cycles, that will help show what im seeing :P

  18. #18

    Thread Starter
    Member
    Join Date
    May 2011
    Posts
    42

    Re: Correct / Incorrect

    Scratch that idea, my net dosnt upload as fast as i thought it would, so on Wednesday im taking what i have to college and going to show my issue to my lecturer and see if he can fathom out what is happening.

    thanks so much though for your help, from where i started im a hell of a lot further than i would be without the help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width