2 Replies - 536 Views - Last Post: 02 July 2013 - 11:02 PM Rate Topic: -----

#1 astaroth  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 02-July 13

Keno Logic Error

Posted 02 July 2013 - 06:24 PM

Hi, I'm somewhat new to the programming scene. Recently I've been working on a Keno program which seemed to be functioning properly until I hit a dead end with a logic error of some sort. In my code I use a counter (count2) to basically check how many matches the player gets in correspondence to the 20 random label values that are output. However, even if a player chooses 5 numbers for example, the program will give me an answer of 20+ which should be near impossible. Any help as to where the error has occurred will be much appreciated.
    Dim count2 As Integer 'second count which basically counts the total matches
        count2 = 0

        If Label1.Text = test Then
            count2 += 1

        ElseIf Label1.Text = test2 Then
            count2 += 1

        ElseIf Label1.Text = test3 Then
            count2 += 1

        ElseIf Label1.Text = test4 Then
            count2 += 1

        ElseIf Label1.Text = test5 Then
            count2 += 1

        ElseIf Label1.Text = test6 Then
            count2 += 1

        ElseIf Label1.Text = test7 Then
            count2 += 1

        ElseIf Label1.Text = test8 Then
            count2 += 1

        ElseIf Label1.Text = test9 Then
            count2 += 1

        ElseIf Label1.Text = test10 Then
            count2 += 1

        ElseIf Label1.Text = test11 Then
            count2 += 1

        ElseIf Label1.Text = test12 Then
            count2 += 1

        ElseIf Label1.Text = test13 Then
            count2 += 1

        ElseIf Label1.Text = test14 Then
            count2 += 1

        ElseIf Label1.Text = test15 Then
            count2 += 1

        ElseIf Label1.Text = test16 Then
            count2 += 1

        ElseIf Label1.Text = test17 Then
            count2 += 1

        ElseIf Label1.Text = test18 Then
            count2 += 1

        ElseIf Label1.Text = test19 Then
            count2 += 1

        ElseIf Label1.Text = test20 Then
            count2 += 1

        ElseIf Label1.Text = test21 Then
            count2 += 1

        ElseIf Label1.Text = test22 Then
            count2 += 1

        ElseIf Label1.Text = test23 Then
            count2 += 1

        ElseIf Label1.Text = test24 Then
            count2 += 1

        ElseIf Label1.Text = test25 Then
            count2 += 1

        ElseIf Label1.Text = test26 Then
            count2 += 1

        ElseIf Label1.Text = test27 Then
            count2 += 1

        ElseIf Label1.Text = test28 Then
            count2 += 1

        ElseIf Label1.Text = test29 Then
            count2 += 1

        ElseIf Label1.Text = test30 Then
            count2 += 1

        ElseIf Label1.Text = test31 Then
            count2 += 1

        ElseIf Label1.Text = test32 Then
            count2 += 1

        ElseIf Label1.Text = test33 Then
            count2 += 1

        ElseIf Label1.Text = test34 Then
            count2 += 1

        ElseIf Label1.Text = test35 Then
            count2 += 1

        ElseIf Label1.Text = test36 Then
            count2 += 1

        ElseIf Label1.Text = test37 Then
            count2 += 1

        ElseIf Label1.Text = test38 Then
            count2 += 1

        ElseIf Label1.Text = test39 Then
            count2 += 1

        ElseIf Label1.Text = test40 Then
            count2 += 1

        ElseIf Label1.Text = test41 Then
            count2 += 1

        ElseIf Label1.Text = test42 Then
            count2 += 1

        ElseIf Label1.Text = test43 Then
            count2 += 1

        ElseIf Label1.Text = test44 Then
            count2 += 1

        ElseIf Label1.Text = test45 Then
            count2 += 1

        ElseIf Label1.Text = test46 Then
            count2 += 1

        ElseIf Label1.Text = test47 Then
            count2 += 1

        ElseIf Label1.Text = test48 Then
            count2 += 1

        ElseIf Label1.Text = test49 Then
            count2 += 1

        ElseIf Label1.Text = test50 Then
            count2 += 1

        ElseIf Label1.Text = test51 Then
            count2 += 1

        ElseIf Label1.Text = test52 Then
            count2 += 1

        ElseIf Label1.Text = test53 Then
            count2 += 1

        ElseIf Label1.Text = test54 Then
            count2 += 1

        ElseIf Label1.Text = test55 Then
            count2 += 1

        ElseIf Label1.Text = test56 Then
            count2 += 1

        ElseIf Label1.Text = test57 Then
            count2 += 1

        ElseIf Label1.Text = test58 Then
            count2 += 1

        ElseIf Label1.Text = test59 Then
            count2 += 1

        ElseIf Label1.Text = test60 Then
            count2 += 1

        ElseIf Label1.Text = test61 Then
            count2 += 1

        ElseIf Label1.Text = test62 Then
            count2 += 1

        ElseIf Label1.Text = test63 Then
            count2 += 1

        ElseIf Label1.Text = test64 Then
            count2 += 1

        ElseIf Label1.Text = test65 Then
            count2 += 1

        ElseIf Label1.Text = test66 Then
            count2 += 1

        ElseIf Label1.Text = test67 Then
            count2 += 1

        ElseIf Label1.Text = test68 Then
            count2 += 1

        ElseIf Label1.Text = test69 Then
            count2 += 1

        ElseIf Label1.Text = test70 Then
            count2 += 1

        ElseIf Label1.Text = test71 Then
            count2 += 1

        ElseIf Label1.Text = test72 Then
            count2 += 1

        ElseIf Label1.Text = test73 Then
            count2 += 1

        ElseIf Label1.Text = test74 Then
            count2 += 1

        ElseIf Label1.Text = test75 Then
            count2 += 1

        ElseIf Label1.Text = test76 Then
            count2 += 1

        ElseIf Label1.Text = test77 Then
            count2 += 1

        ElseIf Label1.Text = test78 Then
            count2 += 1

        ElseIf Label1.Text = test79 Then
            count2 += 1

        ElseIf Label1.Text = test80 Then
            count2 += 1

        Else : count2 += 0
        End If


this snippet basically repeats itself 20 times so I'm thinking the error should lie somewhere in this section.
note: test(1-80) are basically integer values that I've assigned to represent the numbered button being pressed. e.g. when button80 is pressed test80 = 80.
As for the calculation for the points earned, at the moment I'm leaving it as amount of matches x 5 but i don't think the error is in this part.
  If count2 >= 1 Then
            winnings = count2 * 5
            label21.Text = winnings
            MsgBox("You win " & winnings) 'Calculate the winnings 
        End If
        If count2 = 0 Then
            MsgBox("You must be very unlucky, you got 0 matches")
        End If


Thanks in advance

Is This A Good Question/Topic? 0
  • +

Replies To: Keno Logic Error

#2 lar3ry  Icon User is offline

  • Coding Geezer
  • member icon

Reputation: 310
  • View blog
  • Posts: 1,290
  • Joined: 12-September 12

Re: Keno Logic Error

Posted 02 July 2013 - 09:03 PM

Well, for starters, you are comparing Strings to Integers.

You really need to to put an Option Strict On statement at the top of your code (before the Class statement. See the link in my signature for an explanation of why.

I also notice that you are resetting count2 to o each time you call that snippet.

Of course, you haven't supplied us with the code that calls this snippet, and the problem might lie there.
Was This Post Helpful? 1
  • +
  • -

#3 astaroth  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 02-July 13

Re: Keno Logic Error

Posted 02 July 2013 - 11:02 PM

Oh wow, I can't believe I didn't notice that. Thank you very much, I'll try use Option Strict On from now on.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1