You are on page 1of 4

Public Class Form1

Dim navegador As String = "x"


Dim contadorx As Integer = 0
Dim contadory As Integer = 0
Dim gatitodetector As Integer = 0
Public Function xoy(ByVal nav As String)
If nav = "x" Then
navegador = "0"
Return "x"
Else
navegador = "x"
Return "0"
End If
End Function
Public Sub ganarX()
gatitodetector += 1
If Button1.Text = "x" And Button2.Text = "x" And Button3.Text = "x"
MsgBox("X gana este juego.", MsgBoxStyle.Information, " X Wins.
endofgame()
ElseIf Button4.Text = "x" And Button5.Text = "x" And Button6.Text =
Then
MsgBox("X gana este juego.", MsgBoxStyle.Information, " X Wins.
endofgame()
ElseIf Button7.Text = "x" And Button8.Text = "x" And Button9.Text =
Then
MsgBox("X gana este juego.", MsgBoxStyle.Information, " X Wins.
endofgame()
ElseIf Button1.Text = "x" And Button4.Text = "x" And Button7.Text =
Then
MsgBox("X gana este juego.", MsgBoxStyle.Information, " X Wins.
endofgame()
ElseIf Button2.Text = "x" And Button5.Text = "x" And Button8.Text =
Then
MsgBox("X gana este juego.", MsgBoxStyle.Information, " X Wins.
endofgame()
ElseIf Button3.Text = "x" And Button6.Text = "x" And Button9.Text =
Then
MsgBox("X gana este juego.", MsgBoxStyle.Information, " X Wins.
endofgame()
ElseIf Button1.Text = "x" And Button5.Text = "x" And Button9.Text =
Then
MsgBox("X gana este juego.", MsgBoxStyle.Information, " X Wins.
endofgame()
ElseIf Button3.Text = "x" And Button5.Text = "x" And Button7.Text =
Then
MsgBox("X gana este juego.", MsgBoxStyle.Information, " X Wins.
endofgame()
End If
ganar0()
End Sub
Public Sub ganar0()
If Button1.Text = "0" And Button2.Text = "0" And Button3.Text = "0"
MsgBox("0 gana este juego.", MsgBoxStyle.Information, " 0 Wins.
endofgame2()
ElseIf Button4.Text = "0" And Button5.Text = "0" And Button6.Text =
Then
MsgBox("0 gana este juego.", MsgBoxStyle.Information, " 0 Wins.
endofgame2()
ElseIf Button7.Text = "0" And Button8.Text = "0" And Button9.Text =
Then

Then
")
"x"
")
"x"
")
"x"
")
"x"
")
"x"
")
"x"
")
"x"
")

Then
")
"0"
")
"0"

MsgBox("0 gana este juego.", MsgBoxStyle.Information, " 0 Wins. ")


endofgame2()
ElseIf Button1.Text = "0" And Button4.Text = "0" And Button7.Text = "0"
Then
MsgBox("0 gana este juego.", MsgBoxStyle.Information, " 0 Wins. ")
endofgame2()
ElseIf Button2.Text = "0" And Button5.Text = "0" And Button8.Text = "0"
Then
MsgBox("0 gana este juego.", MsgBoxStyle.Information, " 0 Wins. ")
endofgame2()
ElseIf Button3.Text = "0" And Button6.Text = "0" And Button9.Text = "0"
Then
MsgBox("0 gana este juego.", MsgBoxStyle.Information, " 0 Wins. ")
endofgame2()
ElseIf Button1.Text = "0" And Button5.Text = "0" And Button9.Text = "0"
Then
MsgBox("0 gana este juego.", MsgBoxStyle.Information, " 0 Wins. ")
endofgame2()
ElseIf Button3.Text = "0" And Button5.Text = "0" And Button7.Text = "0"
Then
MsgBox("0 gana este juego.", MsgBoxStyle.Information, " 0 Wins. ")
endofgame2()
ElseIf gatitodetector = 9 Then
MsgBox(" Nadie gana este juego.", MsgBoxStyle.Information, " Nadie g
ana")
gatitodetector = 0
End If
End Sub
Public Sub endofgame()
Button1.Enabled = False
Button2.Enabled = False
Button3.Enabled = False
Button4.Enabled = False
Button5.Enabled = False
Button6.Enabled = False
Button7.Enabled = False
Button8.Enabled = False
Button9.Enabled = False
contadorx += 1
gatitodetector = 0
lblContadorX.Text = contadorx.ToString
End Sub
Public Sub endofgame2()
Button1.Enabled = False
Button2.Enabled = False
Button3.Enabled = False
Button4.Enabled = False
Button5.Enabled = False
Button6.Enabled = False
Button7.Enabled = False
Button8.Enabled = False
Button9.Enabled = False
contadory += 1
gatitodetector = 0
lblContadorY.Text = contadory.ToString
End Sub
Public Sub resetiar()
Button1.Enabled = True
Button2.Enabled = True
Button3.Enabled = True

Button4.Enabled = True
Button5.Enabled = True
Button6.Enabled = True
Button7.Enabled = True
Button8.Enabled = True
Button9.Enabled = True
Button1.Text = ""
Button2.Text = ""
Button3.Text = ""
Button4.Text = ""
Button5.Text = ""
Button6.Text = ""
Button7.Text = ""
Button8.Text = ""
Button9.Text = ""
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.E
ventArgs) Handles Button1.Click
Button1.Text = xoy(navegador)
Button1.Enabled = False
ganarX()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.E
ventArgs) Handles Button2.Click
Button2.Text = xoy(navegador)
Button2.Enabled = False
ganarX()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.E
ventArgs) Handles Button3.Click
Button3.Text = xoy(navegador)
Button3.Enabled = False
ganarX()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.E
ventArgs) Handles Button4.Click
Button4.Text = xoy(navegador)
Button4.Enabled = False
ganarX()
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.E
ventArgs) Handles Button5.Click
Button5.Text = xoy(navegador)
Button5.Enabled = False
ganarX()
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.E
ventArgs) Handles Button6.Click
Button6.Text = xoy(navegador)
Button6.Enabled = False
ganarX()
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.E
ventArgs) Handles Button7.Click

Button7.Text = xoy(navegador)
Button7.Enabled = False
ganarX()
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.E
ventArgs) Handles Button8.Click
Button8.Text = xoy(navegador)
Button8.Enabled = False
ganarX()
End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.E
ventArgs) Handles Button9.Click
Button9.Text = xoy(navegador)
Button9.Enabled = False
ganarX()
End Sub
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles ExitToolStripMenuItem.Click
Me.Close()
End Sub
Private Sub NewGaToolStripMenuItem_Click(ByVal sender As System.Object, ByVa
l e As System.EventArgs) Handles NewGaToolStripMenuItem.Click
resetiar()
gatitodetector = 0
End Sub
End Class

You might also like