Results 1 to 4 of 4

Thread: [RESOLVED] Need Help fixing bingo game

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2009
    Posts
    13

    Resolved [RESOLVED] Need Help fixing bingo game

    Im having trouble getting the numbers in my bingo game turning red when they match a set of 8 random numbers. If someone could find out where i've gone wrong i would be most appreciative.

    Code:
    Private Sub CmdStart_Click()
    
    Dim Bingo(4, 4) As Integer, Column As Integer, Row As Integer
    Dim Outer As Integer, Inner As Integer, List As Integer, Temp As Integer
    Dim Number(8) As Integer, Counter As Integer, Pointer As Integer, Value As Integer
      
    Call Generate(Row, Column, Bingo(), Outer, Inner, Temp)
    Call Generate2(Number(), Pointer, Counter)
    Call Generate3(Bingo())
    Call Generate4(Pointer, Number(), Bingo())
    
    End Sub
    
    Private Sub Generate(ByRef Row As Integer, Column As Integer, Bingo() As Integer, ByVal Outer As Integer, Inner As Integer, Temp As Integer)
    
    For Row = 0 To 4
        For Column = 0 To 4
            Bingo(Row, Column) = Rnd * 15 + (15 * Column + 1)
            If Bingo(Row, Column) = 76 Or 0 Then              'GENERATES THE RANDOM NUMBERS ON THE
                Bingo(Row, Column) = 75                       'BINGO SHEET
            End If
        Next Column
    Next Row
    For Outer = 0 To 4
        For Inner = 0 To 4
            For Column = 0 To 4
                If Bingo(Outer, Column) = Bingo(Inner, Column) And Outer <> Inner Then
                    Bingo(Outer, Column) = Rnd * 15 + (15 * Column + 1)
                End If                                                   'MAKES SURE THAT THERE ARE NO
                If Bingo(Outer, Column) = 76 Or 0 Then                   'DUPLICATES ON THE BINGO SHEET
                   Bingo(Outer, Column) = 75
                End If
            Next Column
        Next Inner
    Next Outer
    For Inner = 0 To 4
        For Outer = Inner + 1 To 4
            For Column = 0 To 4
                If Bingo(Outer, Column) < Bingo(Inner, Column) Then
                    Temp = Bingo(Outer, Column)                      'SORTS THE NUMBERS ON THE BINGO SHEET
                    Bingo(Outer, Column) = Bingo(Inner, Column)      'FROM SMALLEST AT TOP TO LARGEST AT BOTTOM
                    Bingo(Inner, Column) = Temp
                End If
            Next Column
        Next Outer
    Next Inner
    PicDisplay2.Print "Randomly Generated Numbers Are As Follows:"     'DISPLAYS THE TITLE FOR THE SECOND
    PicDisplay2.Print                                                  'PICTURE BOX
    
    End Sub
    
    Private Sub Generate2(ByRef Number() As Integer, Pointer As Integer, ByVal Counter As Integer)
    
    For Pointer = 0 To 7
        Number(Pointer) = Rnd * 75                                     'CREATES THE RANDOM EIGHT NUMBERS CALLED
    Next Pointer
    For Counter = 0 To 7
        For Pointer = 0 To 7
            If Number(Pointer) = Number(Counter) And Counter <> Pointer Then
                Number(Pointer) = Rnd * 75
            End If
        Next Pointer
    Next Counter
    PicDisplay2.Print Number(0); Number(1); Number(2); Number(3); Number(4); Number(5); Number(6); Number(7)
    
    End Sub
    Private Sub Generate3(ByRef Bingo() As Integer)
    
    PicA.Print Bingo(0, 0)
    PicB.Print Bingo(1, 0)
    PicC.Print Bingo(2, 0)
    PicD.Print Bingo(3, 0)
    PicE.Print Bingo(4, 0)
    PicF.Print Bingo(0, 1)
    PicG.Print Bingo(1, 1)
    PicH.Print Bingo(2, 1)
    PicI.Print Bingo(3, 1)
    PicJ.Print Bingo(4, 1)
    PicK.Print Bingo(0, 2)
    PicL.Print Bingo(1, 2)
    PicM.Print Bingo(2, 2)
    PicN.Print Bingo(3, 2)
    PicO.Print Bingo(4, 2)
    PicP.Print Bingo(0, 3)
    PicQ.Print Bingo(1, 3)
    PicR.Print Bingo(2, 3)
    PicS.Print Bingo(3, 3)
    PicT.Print Bingo(4, 3)
    PicU.Print Bingo(0, 4)
    PicV.Print Bingo(1, 4)
    PicW.Print Bingo(2, 4)
    PicX.Print Bingo(3, 4)
    PicY.Print Bingo(4, 4)
    
    End Sub
    Private Sub Generate4(ByRef Pointer As Integer, Number() As Integer, Bingo() As Integer)
    
    For Pointer = 0 To 7
    Select Case Number(Pointer)
    Case Is = Bingo(0, 0)
    PicA.ForeColor = vbRed
    Case Is = Bingo(1, 0)
    PicB.ForeColor = vbRed
    Case Is = Bingo(2, 0)
    PicC.ForeColor = vbRed
    Case Is = Bingo(3, 0)
    PicD.ForeColor = vbRed
    Case Is = Bingo(4, 0)
    PicE.ForeColor = vbRed
    Case Is = Bingo(0, 1)
    PicF.ForeColor = vbRed
    Case Is = Bingo(1, 1)
    PicG.ForeColor = vbRed
    Case Is = Bingo(2, 1)
    PicH.ForeColor = vbRed
    Case Is = Bingo(3, 1)
    PicI.ForeColor = vbRed
    Case Is = Bingo(4, 1)
    PicJ.ForeColor = vbRed
    Case Is = Bingo(0, 2)
    PicK.ForeColor = vbRed
    Case Is = Bingo(1, 2)
    PicL.ForeColor = vbRed
    Case Is = Bingo(2, 2)
    PicM.ForeColor = vbRed
    Case Is = Bingo(3, 2)
    PicN.ForeColor = vbRed
    Case Is = Bingo(4, 2)
    PicO.ForeColor = vbRed
    Case Is = Bingo(0, 3)
    PicP.ForeColor = vbRed
    Case Is = Bingo(1, 3)
    PicQ.ForeColor = vbRed
    Case Is = Bingo(2, 3)
    PicR.ForeColor = vbRed
    Case Is = Bingo(3, 3)
    PicS.ForeColor = vbRed
    Case Is = Bingo(4, 3)
    PicT.ForeColor = vbRed
    Case Is = Bingo(0, 4)
    PicU.ForeColor = vbRed
    Case Is = Bingo(1, 4)
    PicV.ForeColor = vbRed
    Case Is = Bingo(2, 4)
    PicW.ForeColor = vbRed
    Case Is = Bingo(3, 4)
    PicX.ForeColor = vbRed
    Case Is = Bingo(4, 4)
    PicY.ForeColor = vbRed
    End Select
    Next Pointer
    
    End Sub
    Private Sub CmdClear_Click()
    
    PicDisplay2.Cls 'CLEARS THE SCREENS DISPLAY BOXES
    PicA.Cls
    PicB.Cls
    PicC.Cls
    PicD.Cls
    PicE.Cls
    PicF.Cls
    PicG.Cls
    PicH.Cls
    PicI.Cls
    PicJ.Cls
    PicK.Cls
    PicL.Cls
    PicM.Cls
    PicN.Cls
    PicO.Cls
    PicP.Cls
    PicQ.Cls
    PicR.Cls
    PicS.Cls
    PicT.Cls
    PicU.Cls
    PicV.Cls
    PicW.Cls
    PicX.Cls
    PicY.Cls
    
    End Sub
    
    Private Sub CmdExit_Click()
        End                      'EXITS THE PROGRAM
    End Sub

  2. #2
    Addicted Member
    Join Date
    Apr 2009
    Location
    Toronto, Ontario
    Posts
    242

    Re: Need Help fixing bingo game

    This code is not VB.NET, since it seems vbRed is not a .NET constant and the code does not even come close to compiling in VB.NET, but appears to be VB6. I've notified the moderators to move the thread.

    You say you're having trouble but you don't specify the trouble you're having. Are you getting errors? What are they? Where do the errors appear during debug?

    From what I can see, except for the non-standard (to me) format of the Select Case statement, this should work.

    -EM.
    ---
    REMEMBER: If your issue is resolved, use the Thread Tools menu to set it as such, and be sure to rate the posts that help you the most!


    Just because I was jealous of g4hsean!

  3. #3
    Addicted Member Dark Anima's Avatar
    Join Date
    Sep 2008
    Posts
    183

    Re: Need Help fixing bingo game

    Uh oh, use control arrays.

  4. #4

    Thread Starter
    New Member
    Join Date
    Nov 2009
    Posts
    13

    Re: Need Help fixing bingo game

    Im apologise for misdirecting the query. I've stated above that there is a problem with the matching of my eight random numbers with my array.
    Thanks you for redirecting the post, much appreciated.

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