   need some assistance- connect four
  allright, im trying to program connect four in vb.net and im getting a little bit mixed up. basically, in this cheap form of it, every space is a button. What im trying to figure out is, how do i make the program check to see if a button is clicked, then to assign the players color piece to the lowest available space in a column. Also, how do i cycle through all of the possible winning column, rows and diagonals, to see if either player won. heres what i have so for, sorry for no comments. basically, the clm's are for to determine which space in the column to change the color for. So, if the player clicks on any button in the column, it will subtract one from clm, and that is the space, but i do i assign the button? Private C4(5, 6) As String    Private record(1) As Integer    Private player As String = "Red"    Private clm1 As Integer = 6    Private clm2 As Integer = 6    Private clm3 As Integer = 6    Private clm4 As Integer = 6    Private clm5 As Integer = 6    Private clm6 As Integer = 6    Private clm7 As Integer = 6    Private Sub btnMove(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn00.Click, btn01.Click, btn02.Click, btn03.Click, btn04.Click, btn05.Click, btn06.Click, btn10.Click, btn11.Click, btn12.Click, btn13.Click, btn14.Click, btn15.Click, btn16.Click, btn20.Click, btn21.Click, btn22.Click, btn23.Click, btn24.Click, btn25.Click, btn26.Click, btn30.Click, btn31.Click, btn32.Click, btn33.Click, btn34.Click, btn35.Click, btn36.Click, btn40.Click, btn41.Click, btn42.Click, btn43.Click, btn44.Click, btn45.Click, btn46.Click, btn50.Click, btn51.Click, btn52.Click, btn53.Click, btn54.Click, btn55.Click, btn56.Click   Dim btnSquare As Button = sender   If btnSquare.Text <> Nothing Then  MessageBox.Show("invalid move", "Stop Cheating")   Else  btnSquare.Text = player  Dim index As String = btnSquare.Tag  Dim row As Integer = Integer.Parse(index.Chars(0))  Dim col As Integer = Integer.Parse(index.Chars(1))  storeMove(row, col, player)  If checkWin() Then MessageBox.Show("Game Over", "Winner") lockButtons() If player = "X" Thenrecord(0) += 1 Elserecord(1) += 1 End If  Else If player = "X" Thenplayer = "O" Elseplayer = "X" End If  End If   End If    End Sub    Private Sub mnuQuit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuQuit.Click   Me.Close()    End Sub    Private Sub mnuRestart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuRestart.Click   btn00.BackColor = Color.Empty   btn01.BackColor = Color.Empty   btn02.BackColor = Color.Empty   btn03.BackColor = Color.Empty   btn04.BackColor = Color.Empty   btn05.BackColor = Color.Empty   btn06.BackColor = Color.Empty   btn10.BackColor = Color.Empty   btn11.BackColor = Color.Empty   btn12.BackColor = Color.Empty   btn13.BackColor = Color.Empty   btn14.BackColor = Color.Empty   btn15.BackColor = Color.Empty   btn16.BackColor = Color.Empty   btn20.BackColor = Color.Empty   btn21.BackColor = Color.Empty   btn22.BackColor = Color.Empty   btn23.BackColor = Color.Empty   btn24.BackColor = Color.Empty   btn25.BackColor = Color.Empty   btn26.BackColor = Color.Empty   btn30.BackColor = Color.Empty   btn31.BackColor = Color.Empty   btn32.BackColor = Color.Empty   btn33.BackColor = Color.Empty   btn34.BackColor = Color.Empty   btn35.BackColor = Color.Empty   btn36.BackColor = Color.Empty   btn40.BackColor = Color.Empty   btn41.BackColor = Color.Empty   btn42.BackColor = Color.Empty   btn43.BackColor = Color.Empty   btn44.BackColor = Color.Empty   btn45.BackColor = Color.Empty   btn46.BackColor = Color.Empty   btn50.BackColor = Color.Empty   btn51.BackColor = Color.Empty   btn52.BackColor = Color.Empty   btn53.BackColor = Color.Empty   btn54.BackColor = Color.Empty   btn55.BackColor = Color.Empty   btn56.BackColor = Color.Empty   player = "red"    End Sub    Private Sub mnuAbout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuAbout.Click   MessageBox.Show("Programmers: James Williams, Tom Elwood, Luis quintero" & ControlChars.NewLine & "Version 1.0")    End SubEnd Class
  I've never used vb.net, however a quick browse of the code suggests a couple of things:1) Use arrays to hold your board state - each space on the board can be in 3 possible states: red, yellow or empty. I'm guessing there are 7 columns and 6 rows (I don't have a set handy), but from a quick google search it seems VB.NET is pretty different to VB6, which was the last version I even looked at.2) Using 56 individual buttons is going to land you with a SERIOUSLY large program, because you can't take advantage of the fact that the rules are fairly simple and will have to write pretty much separate code depending on how many tokens are in a column. This leaves you two options really - either have just 7 buttons (one for each column), and custom draw them (believe me this WILL save time in the end), or just use custom event handling for the whole area. You could also put the 56 button objects into an array and that would take out the repetition but it's not a method I'd recommend.   ;Quote:Original post by ZQJI've never used vb.net, however a quick browse of the code suggests a couple of things:1) Use arrays to hold your board state - each space on the board can be in 3 possible states: red, yellow or empty. I'm guessing there are 7 columns and 6 rows (I don't have a set handy), but from a quick google search it seems VB.NET is pretty different to VB6, which was the last version I even looked at.2) Using 56 individual buttons is going to land you with a SERIOUSLY large program, because you can't take advantage of the fact that the rules are fairly simple and will have to write pretty much separate code depending on how many tokens are in a column. This leaves you two options really - either have just 7 buttons (one for each column), and custom draw them (believe me this WILL save time in the end), or just use custom event handling for the whole area. You could also put the 56 button objects into an array and that would take out the repetition but it's not a method I'd recommend.i actually do have an array, thats what the C4(5, 6). but could u explain the 7 buttons, cause what i dont understand is, if u use 7 buttons, u cant us and individual color for every section. but im still kinda new to vb, so could someone just explain that to me. basically, i already know how to check for win, im just wondering how to cycle through and assign the colors. What i just thought of was is there is 7 main buttons, u click that button to determin what column to drop the piece down so...psuedo:if firstcolumn.click...put piece in last available spaceif secondcolumn.clickbla bla blaBasically, there will be a clm variable for each column. IF the user clicks the certain columns main button, subtract one from clm, and watever the number is, that is the space that is colored, u see?