Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Form1
- Dim turn As Integer
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- turn = 1
- End Sub
- Private Sub win()
- If Button1.Text = "x" And Button2.Text = "x" And Button3.Text = "x" Then
- MsgBox("jogador X ganhou!")
- Label5.Text += 1
- Call disablebuttons()
- End If
- If Button4.Text = "x" And Button5.Text = "x" And Button6.Text = "x" Then
- MsgBox("jogador X ganhou!")
- Label5.Text += 1
- Call disablebuttons()
- End If
- If Button7.Text = "x" And Button8.Text = "x" And Button9.Text = "x" Then
- MsgBox("jogador X ganhou!")
- Label5.Text += 1
- Call disablebuttons()
- End If
- If Button1.Text = "x" And Button4.Text = "x" And Button7.Text = "x" Then
- MsgBox("jogador X ganhou!")
- Label5.Text += 1
- Call disablebuttons()
- End If
- If Button2.Text = "x" And Button5.Text = "x" And Button8.Text = "x" Then
- MsgBox("jogador X ganhou!")
- Label5.Text += 1
- Call disablebuttons()
- End If
- If Button3.Text = "x" And Button6.Text = "x" And Button9.Text = "x" Then
- MsgBox("jogador X ganhou!")
- Label5.Text += 1
- Call disablebuttons()
- End If
- If Button1.Text = "x" And Button5.Text = "x" And Button9.Text = "x" Then
- MsgBox("jogador X ganhou!")
- Label5.Text += 1
- Call disablebuttons()
- End If
- If Button3.Text = "x" And Button5.Text = "x" And Button7.Text = "x" Then
- MsgBox("jogador X ganhou!")
- Label5.Text += 1
- Call disablebuttons()
- End If
- If Button1.Text = "o" And Button2.Text = "o" And Button3.Text = "o" Then
- MsgBox("jogador o ganhou!")
- Label6.Text += 1
- Call disablebuttons()
- End If
- If Button4.Text = "o" And Button5.Text = "o" And Button6.Text = "o" Then
- MsgBox("jogador o ganhou!")
- Label6.Text += 1
- Call disablebuttons()
- End If
- If Button7.Text = "o" And Button8.Text = "o" And Button9.Text = "o" Then
- MsgBox("jogador o ganhou!")
- Label6.Text += 1
- Call disablebuttons()
- End If
- If Button1.Text = "o" And Button4.Text = "o" And Button7.Text = "o" Then
- MsgBox("jogador o ganhou!")
- Label6.Text += 1
- Call disablebuttons()
- End If
- If Button2.Text = "o" And Button5.Text = "o" And Button8.Text = "o" Then
- MsgBox("jogador o ganhou!")
- Label6.Text += 1
- Call disablebuttons()
- End If
- If Button3.Text = "o" And Button6.Text = "o" And Button9.Text = "o" Then
- MsgBox("jogador o ganhou!")
- Label6.Text += 1
- Call disablebuttons()
- End If
- If Button1.Text = "o" And Button5.Text = "o" And Button9.Text = "o" Then
- MsgBox("jogador o ganhou!")
- Label6.Text += 1
- Call disablebuttons()
- End If
- If Button3.Text = "o" And Button5.Text = "o" And Button7.Text = "o" Then
- MsgBox("jogador o ganhou!")
- Label6.Text += 1
- Call disablebuttons()
- End If
- End Sub
- Private Sub disablebuttons()
- 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
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- If turn = 1 Then
- Button1.Text = "x"
- Label2.Text = "o"
- Else
- Button1.Text = "o"
- Label2.Text = "x"
- End If
- turn += 1
- If turn > 2 Then
- turn = 1
- End If
- Call win()
- Button1.Enabled = False
- End Sub
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- If turn = 1 Then
- Button2.Text = "x"
- Label2.Text = "o"
- Else
- Button2.Text = "o"
- Label2.Text = "x"
- End If
- turn += 1
- If turn > 2 Then
- turn = 1
- End If
- Call win()
- Button2.Enabled = False
- End Sub
- Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
- If turn = 1 Then
- Button3.Text = "x"
- Label2.Text = "o"
- Else
- Button3.Text = "o"
- Label2.Text = "x"
- End If
- turn += 1
- If turn > 2 Then
- turn = 1
- End If
- Call win()
- Button3.Enabled = False
- End Sub
- Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
- If turn = 1 Then
- Button4.Text = "x"
- Label2.Text = "o"
- Else
- Button4.Text = "o"
- Label2.Text = "x"
- End If
- turn += 1
- If turn > 2 Then
- turn = 1
- End If
- Call win()
- Button4.Enabled = False
- End Sub
- Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
- If turn = 1 Then
- Button5.Text = "x"
- Label2.Text = "o"
- Else
- Button5.Text = "o"
- Label2.Text = "x"
- End If
- turn += 1
- If turn > 2 Then
- turn = 1
- End If
- Call win()
- Button5.Enabled = False
- End Sub
- Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
- If turn = 1 Then
- Button6.Text = "x"
- Label2.Text = "o"
- Else
- Button6.Text = "o"
- Label2.Text = "x"
- End If
- turn += 1
- If turn > 2 Then
- turn = 1
- End If
- Call win()
- Button6.Enabled = False
- End Sub
- Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
- If turn = 1 Then
- Button7.Text = "x"
- Label2.Text = "o"
- Else
- Button7.Text = "o"
- Label2.Text = "x"
- End If
- turn += 1
- If turn > 2 Then
- turn = 1
- End If
- Call win()
- Button7.Enabled = False
- End Sub
- Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
- If turn = 1 Then
- Button8.Text = "x"
- Label2.Text = "o"
- Else
- Button8.Text = "o"
- Label2.Text = "x"
- End If
- turn += 1
- If turn > 2 Then
- turn = 1
- End If
- Call win()
- Button8.Enabled = False
- End Sub
- Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
- If turn = 1 Then
- Button9.Text = "x"
- Label2.Text = "o"
- Else
- Button9.Text = "o"
- Label2.Text = "x"
- End If
- turn += 1
- If turn > 2 Then
- turn = 1
- End If
- Call win()
- Button9.Enabled = False
- 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
- 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
- Label5.Text = "0"
- Label6.Text = "0"
- End Sub
- End Class
- Att: mchiappinam
Add Comment
Please, Sign In to add comment