Рет қаралды 5,188
In this video, we are going to learn how to make Tic Tac Toe in PowerPoint. This is step-by-step tutorial, easy to understand. The language using here is VBA to code the game.
Please Like, Share and Subscribe
Code for this game---
Option Explicit
Dim flag As Boolean
Dim a As Integer
Dim b As Integer
Private Sub CommandButton1_Click()
If flag = False Then
CommandButton1.Caption = "X"
flag = True
Else
CommandButton1.Caption = "0"
flag = False
End If
Call win
End Sub
#Do it for CommandButton2 to CommandButton9
Private Sub CommandButton10_Click()
CommandButton1.Caption = ""
CommandButton2.Caption = ""
CommandButton3.Caption = ""
CommandButton4.Caption = ""
CommandButton5.Caption = ""
CommandButton6.Caption = ""
CommandButton7.Caption = ""
CommandButton8.Caption = ""
CommandButton9.Caption = ""
End Sub
Private Sub win()
If CommandButton1.Caption = "X" And CommandButton2.Caption = "X" And CommandButton3.Caption = "X" Then
MsgBox ("Hurray!! Player X Win")
a = a + 1
CommandButton13.Caption = a
End If
If CommandButton1.Caption = "X" And CommandButton5.Caption = "X" And CommandButton9.Caption = "X" Then
MsgBox ("Hurray!! Player X Win")
a = a + 1
CommandButton13.Caption = a
End If
If CommandButton1.Caption = "X" And CommandButton4.Caption = "X" And CommandButton7.Caption = "X" Then
MsgBox ("Hurray!! Player X Win")
a = a + 1
CommandButton13.Caption = a
End If
If CommandButton2.Caption = "X" And CommandButton5.Caption = "X" And CommandButton8.Caption = "X" Then
MsgBox ("Hurray!! Player X Win")
a = a + 1
CommandButton13.Caption = a
End If
If CommandButton3.Caption = "X" And CommandButton5.Caption = "X" And CommandButton7.Caption = "X" Then
MsgBox ("Hurray!! Player X Win")
a = a + 1
CommandButton13.Caption = a
End If
If CommandButton3.Caption = "X" And CommandButton6.Caption = "X" And CommandButton9.Caption = "X" Then
MsgBox ("Hurray!! Player X Win")
a = a + 1
CommandButton13.Caption = a
End If
If CommandButton4.Caption = "X" And CommandButton5.Caption = "X" And CommandButton6.Caption = "X" Then
MsgBox ("Hurray!! Player X Win")
a = a + 1
CommandButton13.Caption = a
End If
If CommandButton7.Caption = "X" And CommandButton8.Caption = "X" And CommandButton9.Caption = "X" Then
MsgBox ("Hurray!! Player X Win")
a = a + 1
CommandButton13.Caption = a
End If
If CommandButton1.Caption = "0" And CommandButton2.Caption = "0" And CommandButton3.Caption = "0" Then
MsgBox ("Hurray!! Player 0 Win")
b = b + 1
CommandButton12.Caption = b
End If
If CommandButton1.Caption = "0" And CommandButton5.Caption = "0" And CommandButton9.Caption = "0" Then
MsgBox ("Hurray!! Player 0 Win")
b = b + 1
CommandButton12.Caption = b
End If
If CommandButton1.Caption = "0" And CommandButton4.Caption = "0" And CommandButton7.Caption = "0" Then
MsgBox ("Hurray!! Player X Win")
b = b + 1
CommandButton12.Caption = b
End If
If CommandButton2.Caption = "0" And CommandButton5.Caption = "0" And CommandButton8.Caption = "0" Then
MsgBox ("Hurray!! Player 0 Win")
b = b + 1
CommandButton12.Caption = b
End If
If CommandButton3.Caption = "0" And CommandButton5.Caption = "0" And CommandButton7.Caption = "0" Then
MsgBox ("Hurray!! Player 0 Win")
b = b + 1
CommandButton12.Caption = b
End If
If CommandButton3.Caption = "0" And CommandButton6.Caption = "0" And CommandButton9.Caption = "0" Then
MsgBox ("Hurray!! Player 0 Win")
b = b + 1
CommandButton12.Caption = b
End If
If CommandButton4.Caption = "0" And CommandButton5.Caption = "0" And CommandButton6.Caption = "0" Then
MsgBox ("Hurray!! Player 0 Win")
b = b + 1
CommandButton12.Caption = b
End If
If CommandButton7.Caption = "0" And CommandButton8.Caption = "0" And CommandButton9.Caption = "0" Then
MsgBox ("Hurray!! Player 0 Win")
b = b + 1
CommandButton12.Caption = b
End If
End Sub
Private Sub CommandButton11_Click()
CommandButton1.Caption = ""
CommandButton2.Caption = ""
CommandButton3.Caption = ""
CommandButton4.Caption = ""
CommandButton5.Caption = ""
CommandButton6.Caption = ""
CommandButton7.Caption = ""
CommandButton8.Caption = ""
CommandButton9.Caption = ""
a = 0
CommandButton13.Caption = a
b = 0
CommandButton12.Caption = b
End Sub
For more Gaming videos::
How to create Memory Games-
• How to create Memory g...
How to create Word Scramble game-
• How to make Word Scram...
How to create a board game using dice-
• How to make a creative...