Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Verifica As Boolean
- Public Cont, X, Y As Byte
- Public Ganhador, Ganhador1 As String
- Private Sub BtnIniciar_Click()
- AtivaBotoes
- LimpaMesa
- Cont = 0
- Label1.Caption = "Começa jogando o nome que tem o " & Ganhador1
- End Sub
- Private Sub Form_load()
- LblPrimeiro.Caption = primeiro
- LblSegundo.Caption = segundo
- Verifica = True
- Cont = 0
- End Sub
- Private Sub mesa0_Click()
- If Verifica = True Then
- mesa0.Caption = "x"
- Verifica = False
- mesa0.Enabled = False
- X = X + 1
- Else
- mesa0.Caption = "0"
- Verifica = True
- mesa0.Enabled = False
- Y = Y + 1
- End If
- Cont = Cont + 1
- verificaGanhador
- End Sub
- Private Sub Mesa1_Click()
- If Verifica = True Then
- mesa1.Caption = "X"
- Verifica = False
- mesa1.Enabled = False
- X = X + 1
- Else
- mesa1.Caption = "0"
- Verifica = True
- mesa1.Enabled = False
- Y = Y + 1
- End If
- Cont = Cont + 1
- verificaGanhador
- End Sub
- Private Sub Mesa2_Click()
- If Verifica = True Then
- mesa2.Caption = "X"
- Verifica = False
- mesa2.Enabled = False
- X = X + 1
- Else
- mesa2.Caption = "0"
- Verifica = True
- mesa2.Enabled = False
- Y = Y + 1
- End If
- Cont = Cont + 1
- verificaGanhador
- End Sub
- Private Sub Mesa3_Click()
- If Verifica = True Then
- mesa3.Caption = "X"
- Verifica = False
- mesa3.Enabled = False
- X = X + 1
- Else
- mesa3.Caption = "0"
- Verifica = True
- mesa3.Enabled = False
- Y = Y + 1
- End If
- Cont = Cont + 1
- verificaGanhador
- End Sub
- Private Sub Mesa4_Click()
- If Verifica = True Then
- mesa.Caption = "X"
- Verifica = False
- mesa4.Enabled = False
- X = X + 1
- Else
- mesa4.Caption = "0"
- Verifica = True
- mesa4.Enabled = False
- Y = Y + 1
- End If
- Cont = Cont + 1
- verificaGanhador
- End Sub
- Private Sub Mesa5_Click()
- If Verifica = True Then
- mesa5.Caption = "X"
- Verifica = False
- mesa5.Enabled = False
- X = X + 1
- Else
- mesa5.Caption = "0"
- Verifica = True
- mesa5.Enabled = False
- Y = Y + 1
- End If
- Cont = Cont + 1
- verificaGanhador
- End Sub
- Private Sub Mesa6_Click()
- If Verifica = True Then
- mesa6.Caption = "X"
- Verifica = False
- mesa6.Enabled = False
- X = X + 1
- Else
- mesa6.Caption = "0"
- Verifica = True
- mesa6.Enabled = False
- Y = Y + 1
- End If
- Cont = Cont + 1
- verificaGanhador
- End Sub
- Private Sub Mesa7_Click()
- If Verifica = True Then
- mesa7.Caption = "X"
- Verifica = False
- mesa7.Enabled = False
- X = X + 1
- Else
- mesa7.Caption = "0"
- Verifica = True
- mesa7.Enabled = False
- Y = Y + 1
- End If
- Cont = Cont + 1
- verificaGanhador
- End Sub
- Private Sub Mesa8_Click()
- If Verifica = True Then
- mesa8.Caption = "X"
- Verifica = False
- mesa8.Enabled = False
- X = X + 1
- Else
- mesa8.Caption = "0"
- Verifica = True
- mesa8.Enabled = False
- Y = Y + 1
- End If
- Cont = Cont + 1
- verificaGanhador
- End Sub
- Private Sub verificaGanhador()
- If (mesa0.Caption = "x" And mesa1.Caption = "x" And mesa2.Caption = "x") Or (mesa0.Caption = "0" And mesa1.Caption = "0" And mesa2.Caption = "0") Then
- QuemGanhou
- MsgBox "O Ganhador foi: " & Ganhador
- DesativaBotoes
- Somaponto
- Exit Sub
- ElseIf (mesa3.Caption = "x" And mesa4.Caption = "x" And mesa5.Caption = "x") Or (mesa3.Caption = "0" And mesa4.Caption = "0" And mesa5.Caption = "0") Then
- QuemGanhou
- MsgBox "O Ganhador foi: " & Ganhador
- DesativaBotoes
- Somaponto
- Exit Sub
- ElseIf (mesa6.Caption = "x" And mesa7.Caption = "x" And mesa8.Caption = "x") Or (mesa6.Caption = "0" And mesa7.Caption = "0" And mesa8.Caption = "0") Then
- QuemGanhou
- MsgBox "O Ganhador foi: " & Ganhador
- DesativaBotoes
- Somaponto
- Exit Sub
- ElseIf (mesa0.Caption = "x" And mesa3.Caption = "x" And mesa6.Caption = "x") Or (mesa0.Caption = "0" And mesa3.Caption = "0" And mesa6.Caption = "0") Then
- QuemGanhou
- MsgBox "O Ganhador foi: " & Ganhador
- DesativaBotoes
- Somaponto
- Exit Sub
- ElseIf (mesa1.Caption = "x" And mesa4.Caption = "x" And mesa7.Caption = "x") Or (mesa1.Caption = "0" And mesa4.Caption = "0" And mesa7.Caption = "0") Then
- QuemGanhou
- MsgBox "O Ganhador foi: " & Ganhador
- DesativaBotoes
- Somaponto
- Exit Sub
- ElseIf (mesa2.Caption = "x" And mesa5.Caption = "x" And mesa8.Caption = "x") Or (mesa2.Caption = "0" And mesa5.Caption = "0" And mesa8.Caption = "0") Then
- QuemGanhou
- MsgBox "O Ganhador foi: " & Ganhador
- DesativaBotoes
- Somaponto
- Exit Sub
- ElseIf (mesa0.Caption = "x" And mesa4.Caption = "x" And mesa8.Caption = "x") Or (mesa0.Caption = "0" And mesa4.Caption = "0" And mesa8.Caption = "0") Then
- QuemGanhou
- MsgBox "O Ganhador foi: " & Ganhador
- DesativaBotoes
- Somaponto
- Exit Sub
- ElseIf (mesa2.Caption = "x" And mesa4.Caption = "x" And mesa6.Caption = "x") Or (mesa2.Caption = "0" And mesa4.Caption = "0" And mesa6.Caption = "0") Then
- QuemGanhou
- MsgBox "O Ganhador foi: " & Ganhador
- DesativaBotoes
- Somaponto
- Exit Sub
- End If
- If Cont = 9 Then
- MsgBox "Não ouve ganhador", Vblnformation, "Jogo da Velha"
- Ganhador1 = "0"
- Verifica = False
- End If
- End Sub
- Private Sub mnujogosair_Click()
- End
- End Sub
- Private Sub DesativaBotoes()
- mesa0.Enabled = False
- mesa1.Enabled = False
- mesa2.Enabled = False
- mesa3.Enabled = False
- mesa4.Enabled = False
- mesa5.Enabled = False
- mesa6.Enabled = False
- mesa7.Enabled = False
- mesa8.Enabled = False
- End Sub
- Private Sub AtivaBotoes()
- mesa0.Enabled = True
- mesa1.Enabled = True
- mesa2.Enabled = True
- mesa3.Enabled = True
- mesa4.Enabled = True
- mesa5.Enabled = True
- mesa6.Enabled = True
- mesa7.Enabled = True
- mesa8.Enabled = True
- End Sub
- Private Sub QuemGanhou()
- If X > Y Then
- Ganhador = "x"
- Ganhador1 = "0"
- Else
- Ganhador = "x"
- Ganhador1 = "0"
- End If
- End Sub
- Private Sub Somaponto()
- If X > Y Then
- LblPlacarPrimeiro.Caption = Val(LblPlacarPrimeiro.Caption) + 1
- Else
- LblPlacarSegundo.Caption = Val(LblPlacarSegundo.Caption) + 1
- End If
- End Sub
- Private Sub LimpaMesa()
- mesa0.Enabled = ""
- mesa1.Enabled = ""
- mesa2.Enabled = ""
- mesa3.Enabled = ""
- mesa4.Enabled = ""
- mesa5.Enabled = ""
- mesa6.Enabled = ""
- mesa7.Enabled = ""
- mesa8.Enabled = ""
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment