Anda di halaman 1dari 7

Dim flag As Boolean

Private Sub Command10_Click()


Command1.Caption = ""
Command2.Caption = ""
Command3.Caption = ""
Command4.Caption = ""
Command5.Caption = ""
Command6.Caption = ""
Command7.Caption = ""
Command8.Caption = ""
Command9.Caption = ""
End Sub
Private Sub Command1_Click()
If flag = False Then
Command1.Caption = "X"
flag = True
Label5.Caption = "Player O turn"
Else
Command1.Caption = "O"
Label5.Caption = "Player X turn"
flag = False
End If
Win
End Sub
Private Sub Command11_Click()
Label3.Caption = ""
Label4.Caption = ""
End Sub
Private Sub Command2_Click()
If flag = False Then
Command2.Caption = "X"
flag = True
Label5.Caption = "Player O turn"
Else
Command2.Caption = "O"
flag = False
Label5.Caption = "Player X turn"
End If
Win
End Sub
Private Sub Command3_Click()
If flag = False Then
Command3.Caption = "X"
flag = True
Label5.Caption = "Player O turn"
Else
Command3.Caption = "O"
flag = False
Label5.Caption = "Player X turn"
End If
Win
End Sub
Private Sub Command4_Click()
If flag = False Then
Command4.Caption = "X"
flag = True

Label5.Caption = "Player O turn"


Else
Command4.Caption = "O"
flag = False
Label5.Caption = "Player X turn"
End If
Win
End Sub
Private Sub Command5_Click()
If flag = False Then
Command5.Caption = "X"
flag = True
Label5.Caption = "Player O turn"
Else
Command5.Caption = "O"
flag = False
Label5.Caption = "Player X turn"
End If
Win
End Sub
Private Sub Command6_Click()
If flag = False Then
Command6.Caption = "X"
flag = True
Label5.Caption = "Player O turn"
Else
Command6.Caption = "O"
flag = False
Label5.Caption = "Player X turn"
End If
Win
End Sub
Private Sub Command7_Click()
If flag = False Then
Command7.Caption = "X"
flag = True
Label5.Caption = "Player O turn"
Else
Command7.Caption = "O"
flag = False
Label5.Caption = "Player X turn"
End If
Win
End Sub
Private Sub Command8_Click()
If flag = False Then
Command8.Caption = "X"
flag = True
Label5.Caption = "Player X turn"
Else
Command8.Caption = "O"
flag = False
Label5.Caption = "Player X turn"
End If
Win
End Sub

Private Sub Command9_Click()


If flag = False Then
Command9.Caption = "X"
flag = True
Label5.Caption = "Player O turn"
Else
Command9.Caption = "O"
flag = False
Label5.Caption = "Player X turn"
End If
Win
End Sub
Private Sub Win()
If Command1.Caption = "X" And Command2.Caption
Then
MsgBox ("Player X Wins!")
Label3.Caption = Val(Label3.Caption) + Val(1)
Command1.Caption = ""
Command2.Caption = ""
Command3.Caption = ""
Command4.Caption = ""
Command5.Caption = ""
Command6.Caption = ""
Command7.Caption = ""
Command8.Caption = ""
Command9.Caption = ""
End If
If Command1.Caption = "X" And Command4.Caption
Then
MsgBox ("Player X Wins!")
Label3.Caption = Val(Label3.Caption) + Val(1)
Command1.Caption = ""
Command2.Caption = ""
Command3.Caption = ""
Command4.Caption = ""
Command5.Caption = ""
Command6.Caption = ""
Command7.Caption = ""
Command8.Caption = ""
Command9.Caption = ""
End If
If Command1.Caption = "X" And Command5.Caption
Then
MsgBox ("Player X Wins!")
Label3.Caption = Val(Label3.Caption) + Val(1)
Command1.Caption = ""
Command2.Caption = ""
Command3.Caption = ""
Command4.Caption = ""
Command5.Caption = ""
Command6.Caption = ""
Command7.Caption = ""
Command8.Caption = ""
Command9.Caption = ""
End If
If Command2.Caption = "X" And Command5.Caption
Then
MsgBox ("Player X Wins!")

= "X" And Command3.Caption = "X"

= "X" And Command7.Caption = "X"

= "X" And Command9.Caption = "X"

= "X" And Command8.Caption = "X"

Label3.Caption = Val(Label3.Caption) + Val(1)


Command1.Caption = ""
Command2.Caption = ""
Command3.Caption = ""
Command4.Caption = ""
Command5.Caption = ""
Command6.Caption = ""
Command7.Caption = ""
Command8.Caption = ""
Command9.Caption = ""
End If
If Command3.Caption = "X" And Command6.Caption
Then
MsgBox ("Player X Wins!")
Label3.Caption = Val(Label3.Caption) + Val(1)
Command1.Caption = ""
Command2.Caption = ""
Command3.Caption = ""
Command4.Caption = ""
Command5.Caption = ""
Command6.Caption = ""
Command7.Caption = ""
Command8.Caption = ""
Command9.Caption = ""
End If
If Command4.Caption = "X" And Command5.Caption
Then
MsgBox ("Player X Wins!")
Label3.Caption = Val(Label3.Caption) + Val(1)
Command1.Caption = ""
Command2.Caption = ""
Command3.Caption = ""
Command4.Caption = ""
Command5.Caption = ""
Command6.Caption = ""
Command7.Caption = ""
Command8.Caption = ""
Command9.Caption = ""
End If
If Command7.Caption = "X" And Command8.Caption
Then
MsgBox ("Player X Wins!")
Label3.Caption = Val(Label3.Caption) + Val(1)
Command1.Caption = ""
Command2.Caption = ""
Command3.Caption = ""
Command4.Caption = ""
Command5.Caption = ""
Command6.Caption = ""
Command7.Caption = ""
Command8.Caption = ""
Command9.Caption = ""
End If
If Command3.Caption = "X" And Command5.Caption
Then
MsgBox ("Player X Wins!")
Label3.Caption = Val(Label3.Caption) + Val(1)
Command1.Caption = ""
Command2.Caption = ""
Command3.Caption = ""

= "X" And Command9.Caption = "X"

= "X" And Command6.Caption = "X"

= "X" And Command9.Caption = "X"

= "X" And Command7.Caption = "X"

Command4.Caption
Command5.Caption
Command6.Caption
Command7.Caption
Command8.Caption
Command9.Caption
End If

=
=
=
=
=
=

""
""
""
""
""
""

If Command1.Caption = "O" And Command2.Caption


Then
MsgBox ("Player O Wins!")
Label4.Caption = Val(Label4.Caption) + Val(1)
Command1.Caption = ""
Command2.Caption = ""
Command3.Caption = ""
Command4.Caption = ""
Command5.Caption = ""
Command6.Caption = ""
Command7.Caption = ""
Command8.Caption = ""
Command9.Caption = ""
End If
If Command1.Caption = "O" And Command4.Caption
Then
MsgBox ("Player O Wins!")
Label4.Caption = Val(Label4.Caption) + Val(1)
Command1.Caption = ""
Command2.Caption = ""
Command3.Caption = ""
Command4.Caption = ""
Command5.Caption = ""
Command6.Caption = ""
Command7.Caption = ""
Command8.Caption = ""
Command9.Caption = ""
End If
If Command1.Caption = "O" And Command5.Caption
Then
MsgBox ("Player O Wins!")
Label4.Caption = Val(Label4.Caption) + Val(1)
Command1.Caption = ""
Command2.Caption = ""
Command3.Caption = ""
Command4.Caption = ""
Command5.Caption = ""
Command6.Caption = ""
Command7.Caption = ""
Command8.Caption = ""
Command9.Caption = ""
End If
If Command2.Caption = "O" And Command5.Caption
Then
MsgBox ("Player O Wins!")
Label4.Caption = Val(Label4.Caption) + Val(1)
Command1.Caption = ""
Command2.Caption = ""
Command3.Caption = ""
Command4.Caption = ""

= "O" And Command3.Caption = "O"

= "O" And Command7.Caption = "O"

= "O" And Command9.Caption = "O"

= "O" And Command8.Caption = "O"

Command5.Caption = ""
Command6.Caption = ""
Command7.Caption = ""
Command8.Caption = ""
Command9.Caption = ""
End If
If Command3.Caption = "O" And Command6.Caption
Then
MsgBox ("Player O Wins!")
Label4.Caption = Val(Label4.Caption) + Val(1)
Command1.Caption = ""
Command2.Caption = ""
Command3.Caption = ""
Command4.Caption = ""
Command5.Caption = ""
Command6.Caption = ""
Command7.Caption = ""
Command8.Caption = ""
Command9.Caption = ""
End If
If Command4.Caption = "O" And Command5.Caption
Then
MsgBox ("Player O Wins!")
Label4.Caption = Val(Label4.Caption) + Val(1)
Command1.Caption = ""
Command2.Caption = ""
Command3.Caption = ""
Command4.Caption = ""
Command5.Caption = ""
Command6.Caption = ""
Command7.Caption = ""
Command8.Caption = ""
Command9.Caption = ""
End If
If Command7.Caption = "O" And Command8.Caption
Then
MsgBox ("Player O Wins!")
Label4.Caption = Val(Label4.Caption) + Val(1)
Command1.Caption = ""
Command2.Caption = ""
Command3.Caption = ""
Command4.Caption = ""
Command5.Caption = ""
Command6.Caption = ""
Command7.Caption = ""
Command8.Caption = ""
Command9.Caption = ""
End If
If Command3.Caption = "O" And Command5.Caption
Then
MsgBox ("Player O Wins!")
Label4.Caption = Val(Label4.Caption) + Val(1)
Command1.Caption = ""
Command2.Caption = ""
Command3.Caption = ""
Command4.Caption = ""
Command5.Caption = ""
Command6.Caption = ""
Command7.Caption = ""
Command8.Caption = ""

= "O" And Command9.Caption = "O"

= "O" And Command6.Caption = "O"

= "O" And Command9.Caption = "O"

= "O" And Command7.Caption = "O"

Command9.Caption = ""
End If
End Sub

Anda mungkin juga menyukai