SolvedConnect Four

Posts 1–4 of 4 · Page 1 of 1
Connect Four
Well, I've started developing a Connect Four game and I can't seem to figure out why the seventh row doesn't respond like the others do. I coded it the same for each row, but with the according array number.



Check the source and see if you can figure it out.

[X][X]

@Hassan, approve.
Connect Four.rar79 KB · 11 downloads Scanning…
@Sketchy: First, at top of your code, change this line:

Code:
Dim grid(6, 7) As System.Windows.Forms.Button
To

Code:
Dim grid(7, 7) As System.Windows.Forms.Button
Then, in the frmMain designer, double click btn17. It will create a new event handler. You current one is not recognized by the visual studio, so the new one will become:

Code:
Private Sub btn17_Click_1(sender As System.Object, e As System.EventArgs) Handles btn17.Click

End Sub
Inside that, paste the code you originally wrote for btn17. So, the new sub procedure now will be:

Code:
Private Sub btn17_Click_1(sender As System.Object, e As System.EventArgs) Handles btn17.Click
        PlacePiece7()
        CheckForWins()

        If PlayerTurn = "Red" Then
            PlayerTurn = "Blue"
        ElseIf PlayerTurn = "Blue" Then
            PlayerTurn = "Red"
        End If
    End Sub
Working fine now.
Quote Originally Posted by Hassan View Post
@Sketchy: First, at top of your code, change this line:

Code:
Dim grid(6, 7) As System.Windows.Forms.Button
To

Code:
Dim grid(7, 7) As System.Windows.Forms.Button
Then, in the frmMain designer, double click btn17. It will create a new event handler. You current one is not recognized by the visual studio, so the new one will become:

Code:
Private Sub btn17_Click_1(sender As System.Object, e As System.EventArgs) Handles btn17.Click

End Sub
Inside that, paste the code you originally wrote for btn17. So, the new sub procedure now will be:

Code:
Private Sub btn17_Click_1(sender As System.Object, e As System.EventArgs) Handles btn17.Click
        PlacePiece7()
        CheckForWins()

        If PlayerTurn = "Red" Then
            PlayerTurn = "Blue"
        ElseIf PlayerTurn = "Blue" Then
            PlayerTurn = "Red"
        End If
    End Sub
Working fine now.
Sweet, thanks. I was thinking that I mixed up some numbers or something, then kept looking everything over.

I never thought it would be something like this.

/solved
NP. Marked Solved.
Posts 1–4 of 4 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us