Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Form2
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- If turn.Text = "X" Then
- Button1.Text = "X"
- turn.Text = "O"
- Else
- Button1.Text = "O"
- turn.Text = "X"
- End If
- Button1.Enabled = False
- 'player X wins
- If Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- 'player O wins
- If Button1.Text = "O" And Button2.Text = "O" And Button3.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button7.Text = "O" And Button8.Text = "O" And Button9.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button2.Text = "O" And Button5.Text = "O" And Button8.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "O" And Button5.Text = "O" And Button9.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "O" And Button5.Text = "O" And Button7.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Enabled = False And Button2.Enabled = False And Button3.Enabled = False And Button4.Enabled = False _
- And Button5.Enabled = False And Button6.Enabled = False And Button7.Enabled = False And Button8.Enabled = False _
- And Button9.Enabled = False Then MsgBox("Its draw!!!")
- End Sub
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- If turn.Text = "X" Then
- Button2.Text = "X"
- turn.Text = "O"
- Else
- Button2.Text = "O"
- turn.Text = "X"
- End If
- Button2.Enabled = False
- 'player X wins
- If Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- 'player O wins
- If Button1.Text = "O" And Button2.Text = "O" And Button3.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button7.Text = "O" And Button8.Text = "O" And Button9.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button2.Text = "O" And Button5.Text = "O" And Button8.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "O" And Button5.Text = "O" And Button9.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "O" And Button5.Text = "O" And Button7.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Enabled = False And Button2.Enabled = False And Button3.Enabled = False And Button4.Enabled = False _
- And Button5.Enabled = False And Button6.Enabled = False And Button7.Enabled = False And Button8.Enabled = False _
- And Button9.Enabled = False Then MsgBox("Its draw!!!")
- End Sub
- Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
- If turn.Text = "X" Then
- Button3.Text = "X"
- turn.Text = "O"
- Else
- Button3.Text = "O"
- turn.Text = "X"
- End If
- Button3.Enabled = False
- 'player X wins
- If Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- 'player O wins
- If Button1.Text = "O" And Button2.Text = "O" And Button3.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button7.Text = "O" And Button8.Text = "O" And Button9.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button2.Text = "O" And Button5.Text = "O" And Button8.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "O" And Button5.Text = "O" And Button9.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "O" And Button5.Text = "O" And Button7.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Enabled = False And Button2.Enabled = False And Button3.Enabled = False And Button4.Enabled = False _
- And Button5.Enabled = False And Button6.Enabled = False And Button7.Enabled = False And Button8.Enabled = False _
- And Button9.Enabled = False Then MsgBox("Its draw!!!")
- End Sub
- Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
- If turn.Text = "X" Then
- Button4.Text = "X"
- turn.Text = "O"
- Else
- Button4.Text = "O"
- turn.Text = "X"
- End If
- Button4.Enabled = False
- 'player X wins
- If Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- 'player O wins
- If Button1.Text = "O" And Button2.Text = "O" And Button3.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button7.Text = "O" And Button8.Text = "O" And Button9.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button2.Text = "O" And Button5.Text = "O" And Button8.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "O" And Button5.Text = "O" And Button9.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "O" And Button5.Text = "O" And Button7.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Enabled = False And Button2.Enabled = False And Button3.Enabled = False And Button4.Enabled = False _
- And Button5.Enabled = False And Button6.Enabled = False And Button7.Enabled = False And Button8.Enabled = False _
- And Button9.Enabled = False Then MsgBox("Its draw!!!")
- End Sub
- Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
- If turn.Text = "X" Then
- Button5.Text = "X"
- turn.Text = "O"
- Else
- Button5.Text = "O"
- turn.Text = "X"
- End If
- Button5.Enabled = False
- 'player X wins
- If Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- 'player O wins
- If Button1.Text = "O" And Button2.Text = "O" And Button3.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button7.Text = "O" And Button8.Text = "O" And Button9.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button2.Text = "O" And Button5.Text = "O" And Button8.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "O" And Button5.Text = "O" And Button9.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "O" And Button5.Text = "O" And Button7.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Enabled = False And Button2.Enabled = False And Button3.Enabled = False And Button4.Enabled = False _
- And Button5.Enabled = False And Button6.Enabled = False And Button7.Enabled = False And Button8.Enabled = False _
- And Button9.Enabled = False Then MsgBox("Its draw!!!")
- End Sub
- Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
- If turn.Text = "X" Then
- Button6.Text = "X"
- turn.Text = "O"
- Else
- Button6.Text = "O"
- turn.Text = "X"
- End If
- Button6.Enabled = False
- 'player X wins
- If Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- 'player O wins
- If Button1.Text = "O" And Button2.Text = "O" And Button3.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button7.Text = "O" And Button8.Text = "O" And Button9.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button2.Text = "O" And Button5.Text = "O" And Button8.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "O" And Button5.Text = "O" And Button9.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "O" And Button5.Text = "O" And Button7.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Enabled = False And Button2.Enabled = False And Button3.Enabled = False And Button4.Enabled = False _
- And Button5.Enabled = False And Button6.Enabled = False And Button7.Enabled = False And Button8.Enabled = False _
- And Button9.Enabled = False Then MsgBox("Its draw!!!")
- End Sub
- Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
- If turn.Text = "X" Then
- Button7.Text = "X"
- turn.Text = "O"
- Else
- Button7.Text = "O"
- turn.Text = "X"
- End If
- Button7.Enabled = False
- 'player X wins
- If Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- 'player O wins
- If Button1.Text = "O" And Button2.Text = "O" And Button3.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button7.Text = "O" And Button8.Text = "O" And Button9.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button2.Text = "O" And Button5.Text = "O" And Button8.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "O" And Button5.Text = "O" And Button9.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "O" And Button5.Text = "O" And Button7.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Enabled = False And Button2.Enabled = False And Button3.Enabled = False And Button4.Enabled = False _
- And Button5.Enabled = False And Button6.Enabled = False And Button7.Enabled = False And Button8.Enabled = False _
- And Button9.Enabled = False Then MsgBox("Its draw!!!")
- End Sub
- Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
- If turn.Text = "X" Then
- Button8.Text = "X"
- turn.Text = "O"
- Else
- Button8.Text = "O"
- turn.Text = "X"
- End If
- Button8.Enabled = False
- 'player X wins
- If Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- 'player O wins
- If Button1.Text = "O" And Button2.Text = "O" And Button3.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button7.Text = "O" And Button8.Text = "O" And Button9.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button2.Text = "O" And Button5.Text = "O" And Button8.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "O" And Button5.Text = "O" And Button9.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "O" And Button5.Text = "O" And Button7.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Enabled = False And Button2.Enabled = False And Button3.Enabled = False And Button4.Enabled = False _
- And Button5.Enabled = False And Button6.Enabled = False And Button7.Enabled = False And Button8.Enabled = False _
- And Button9.Enabled = False Then MsgBox("Its draw!!!")
- End Sub
- Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
- If turn.Text = "X" Then
- Button9.Text = "X"
- turn.Text = "O"
- Else
- Button9.Text = "O"
- turn.Text = "X"
- End If
- Button9.Enabled = False
- 'player X wins
- If Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "X" Then
- MsgBox("Player X Won!")
- scoreX.Text = Val(scoreX.Text) + 1
- 'player O wins
- End If
- If Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button3.Text = "O" And Button5.Text = "O" And Button7.Text = "O" Then
- MsgBox("Player O Won!")
- scoreO.Text = Val(scoreX.Text) + 1
- End If
- If Button1.Enabled = False And Button2.Enabled = False And Button3.Enabled = False And Button4.Enabled = False _
- And Button5.Enabled = False And Button6.Enabled = False And Button7.Enabled = False And Button8.Enabled = False _
- And Button9.Enabled = False Then MsgBox("Its draw!!!")
- End Sub
- Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
- Button1.Text = " "
- Button1.Enabled = True
- Button2.Text = " "
- Button2.Enabled = True
- Button3.Text = " "
- Button3.Enabled = True
- Button4.Text = " "
- Button4.Enabled = True
- Button5.Text = " "
- Button5.Enabled = True
- Button6.Text = " "
- Button6.Enabled = True
- Button7.Text = " "
- Button7.Enabled = True
- Button8.Text = " "
- Button8.Enabled = True
- Button9.Text = " "
- Button9.Enabled = True
- turn.Text = "X"
- End Sub
- Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
- Button1.Text = " "
- Button1.Enabled = True
- Button2.Text = " "
- Button2.Enabled = True
- Button3.Text = " "
- Button3.Enabled = True
- Button4.Text = " "
- Button4.Enabled = True
- Button5.Text = " "
- Button5.Enabled = True
- Button6.Text = " "
- Button6.Enabled = True
- Button7.Text = " "
- Button7.Enabled = True
- Button8.Text = " "
- Button8.Enabled = True
- Button9.Text = " "
- Button9.Enabled = True
- scoreO.Text = "0"
- scoreX.Text = "0"
- turn.Text = "X"
- End Sub
- Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
- Me.Hide()
- Form1.Show()
- End Sub
- Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
- Me.Hide()
- Form1.Show()
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement