Hi All,
I really need help with this its driving me crazy, I am writing a noughts and crosses game and everything works but the checkwinner sub routine, so basically if someone gets three X's or O's in a row then a message box pops up saying either X has won or O has won. Below is what I have written in the sub routine.
Private Sub CheckWinner()
If btn2.Text = "X" And btn3.Text = "X" And btn4.Text = "X" Then
MessageBox.Show("X Has Won")
ElseIf btn2.Text = "O" And btn3.Text = "O" = btn4.Text = "O" Then
MessageBox.Show("O Has Won")
ElseIf btn5.Text = "X" And btn6.Text = "X" = btn7.Text = "X" Then
MessageBox.Show("X Has Won")
ElseIf btn5.Text = "O" And btn6.Text = "O" = btn7.Text = "O" Then
MessageBox.Show("O Has Won")
ElseIf btn8.Text = "X" And btn9.Text = "X" = btn10.Text = "X" Then
MessageBox.Show("X Has Won")
ElseIf btn8.Text = "O" And btn9.Text = "O" = btn10.Text = "O" Then
MessageBox.Show("O Has Won")
ElseIf btn2.Text = "X" And btn5.Text = "X" = btn8.Text = "X" Then
MessageBox.Show("X Has Won")
ElseIf btn2.Text = "O" And btn5.Text = "O" = btn8.Text = "O" Then
MessageBox.Show("O Has Won")
ElseIf btn3.Text = "X" And btn6.Text = "X" = btn9.Text = "X" Then
MessageBox.Show("X Has Won")
ElseIf btn3.Text = "O" And btn6.Text = "O" = btn9.Text = "O" Then
MessageBox.Show("O Has Won")
ElseIf btn4.Text = "X" And btn7.Text = "X" = btn10.Text = "X" Then
MessageBox.Show("X Has Won")
ElseIf btn4.Text = "O" And btn7.Text = "O" = btn10.Text = "O" Then
MessageBox.Show("O Has Won")
ElseIf btn2.Text = "X" And btn6.Text = "X" = btn10.Text = "X" Then
MessageBox.Show("X Has Won")
ElseIf btn2.Text = "O" And btn6.Text = "O" = btn10.Text = "O" Then
MessageBox.Show("O Has Won")
ElseIf btn8.Text = "X" And btn6.Text = "O" = btn4.Text = "X" Then
MessageBox.Show("X Has Won")
ElseIf btn8.Text = "O" And btn6.Text = "O" = btn4.Text = "O" Then
MessageBox.Show("O Has Won")
End If
End Sub
But nothing happens if I put three X's or three O's are in a row.
Not sure what else to do, can anyone point me in the right direction.
Thanks
John