Private Sub Buttons(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button2.Click, Button3.Click, Button4.Click, Button5.Click, Button6.Click, Button7.Click, Button8.Click, Button9.Click
If flag = False Then
DirectCast(sender, Button).Text = "x"
flag = True
Else
DirectCast(sender, Button).Text = "O"
flag = False
End If
win()
End Sub
Private Sub win()
If Button1.Text = "x" And Button2.Text = "x" And Button3.Text = "x" Then
MsgBox("player X win", MsgBoxStyle.Information)
Label3.Text += 1
Button1.Text = ""
Button2.Text = ""
Button3.Text = ""
Button4.Text = ""
Button5.Text = ""
Button6.Text = ""
Button7.Text = ""
Button8.Text = ""
Button9.Text = ""
End If
If Button1.Text = "x" And Button4.Text = "x" And Button7.Text = "x" Then
Label3.Text += 1
MsgBox("player X win", MsgBoxStyle.Information)
Button1.Text = ""
Button2.Text = ""
Button3.Text = ""
Button4.Text = ""
Button5.Text = ""
Button6.Text = ""
Button7.Text = ""
Button8.Text = ""
Button9.Text = ""
End If
If Button1.Text = "x" And Button5.Text = "x" And Button9.Text = "x" Then
Label3.Text += 1
MsgBox("player X win", MsgBoxStyle.Information)
Button1.Text = ""
Button2.Text = ""
Button3.Text = ""
Button4.Text = ""
Button5.Text = ""
Button6.Text = ""
Button7.Text = ""
Button8.Text = ""
Button9.Text = ""
End If
If Button2.Text = "x" And Button5.Text = "x" And Button8.Text = "x" Then
Label3.Text += 1
MsgBox("player X win", MsgBoxStyle.Information)
Button1.Text = ""
Button2.Text = ""
Button3.Text = ""
Button4.Text = ""
Button5.Text = ""
Button6.Text = ""
Button7.Text = ""
Button8.Text = ""
Button9.Text = ""
End If
If Button3.Text = "x" And Button6.Text = "x" And Button9.Text = "x" Then
Label3.Text += 1
MsgBox("player X win", MsgBoxStyle.Information)
Button1.Text = ""
Button2.Text = ""
Button3.Text = ""
Button4.Text = ""
Button5.Text = ""
Button6.Text = ""
Button7.Text = ""
Button8.Text = ""
End If
If Button3.Text = "x" And Button5.Text = "x" And Button7.Text = "x" Then
If flag = False Then
DirectCast(sender, Button).Text = "x"
flag = True
Else
DirectCast(sender, Button).Text = "O"
flag = False
End If
win()
End Sub
Private Sub win()
If Button1.Text = "x" And Button2.Text = "x" And Button3.Text = "x" Then
MsgBox("player X win", MsgBoxStyle.Information)
Label3.Text += 1
Button1.Text = ""
Button2.Text = ""
Button3.Text = ""
Button4.Text = ""
Button5.Text = ""
Button6.Text = ""
Button7.Text = ""
Button8.Text = ""
Button9.Text = ""
End If
If Button1.Text = "x" And Button4.Text = "x" And Button7.Text = "x" Then
Label3.Text += 1
MsgBox("player X win", MsgBoxStyle.Information)
Button1.Text = ""
Button2.Text = ""
Button3.Text = ""
Button4.Text = ""
Button5.Text = ""
Button6.Text = ""
Button7.Text = ""
Button8.Text = ""
Button9.Text = ""
End If
If Button1.Text = "x" And Button5.Text = "x" And Button9.Text = "x" Then
Label3.Text += 1
MsgBox("player X win", MsgBoxStyle.Information)
Button1.Text = ""
Button2.Text = ""
Button3.Text = ""
Button4.Text = ""
Button5.Text = ""
Button6.Text = ""
Button7.Text = ""
Button8.Text = ""
Button9.Text = ""
End If
If Button2.Text = "x" And Button5.Text = "x" And Button8.Text = "x" Then
Label3.Text += 1
MsgBox("player X win", MsgBoxStyle.Information)
Button1.Text = ""
Button2.Text = ""
Button3.Text = ""
Button4.Text = ""
Button5.Text = ""
Button6.Text = ""
Button7.Text = ""
Button8.Text = ""
Button9.Text = ""
End If
If Button3.Text = "x" And Button6.Text = "x" And Button9.Text = "x" Then
Label3.Text += 1
MsgBox("player X win", MsgBoxStyle.Information)
Button1.Text = ""
Button2.Text = ""
Button3.Text = ""
Button4.Text = ""
Button5.Text = ""
Button6.Text = ""
Button7.Text = ""
Button8.Text = ""
End If
If Button3.Text = "x" And Button5.Text = "x" And Button7.Text = "x" Then
