VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This creates a Tic Tac toe game

by Anthony Roberts (2 Submissions)
Category: Games
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Fri 4th May 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

This creates a Tic Tac toe game

API Declarations


'Name the Form frmTic
'Create Module Toe


Rate This creates a Tic Tac toe game



Private Sub cmdTac1_Click()
intButton = "cmdTac1"
Remove (Tic)
End Sub

Private Sub cmdTac2_Click()
intButton = "cmdTac2"
Remove (Tic)
End Sub

Private Sub cmdTac3_Click()
intButton = "cmdTac3"
Remove (Tic)
End Sub

Private Sub cmdTac4_Click()
intButton = "cmdTac4"
Remove (Tic)
End Sub

Private Sub cmdTac5_Click()
intButton = "cmdTac5"
Remove (Tic)
End Sub

Private Sub cmdTac6_Click()
intButton = "cmdTac6"
Remove (Tic)
End Sub

Private Sub cmdTac7_Click()
intButton = "cmdTac7"
Remove (Tic)
End Sub

Private Sub cmdTac8_Click()
intButton = "cmdTac8"
Remove (Tic)
End Sub

Private Sub cmdTac9_Click()
intButton = "cmdTac9"
Remove (Tic)
End Sub

Private Sub Form_Load()
MsgBox ("X will go fist")
intCounter = 1
End Sub

' Code for the module
Public intCounter As Integer
Public intButton
Public Caption
Public intCat As Integer


Function Remove(Tic)


If intCounter = 1 Then
    frmTic(intButton).Caption = "X"
    intCounter = 0
    frmTic(intButton).Enabled = False
    intCat = intCat + 1
    GoTo ERC
End If

If intCounter = 0 Then
    frmTic(intButton).Caption = "O"
    intCounter = 1
    frmTic(intButton).Enabled = False
    intCat = intCat + 1
    GoTo ERC

End If

ERC:

If frmTic.cmdTac1.Caption = "X" And frmTic.cmdTac2.Caption = "X" And frmTic.cmdTac3.Caption = "X" Or frmTic.cmdTac1.Caption = "X" And frmTic.cmdTac4.Caption = "X" And frmTic.cmdTac7.Caption = "X" Or frmTic.cmdTac1.Caption = "X" And frmTic.cmdTac5.Caption = "X" And frmTic.cmdTac9.Caption = "X" Then
    MsgBox ("Congratulations X you won")
End If

If frmTic.cmdTac4.Caption = "X" And frmTic.cmdTac5.Caption = "X" And frmTic.cmdTac6.Caption = "X" Then
    MsgBox ("Congratulations X you won")
End If

If frmTic.cmdTac7.Caption = "X" And frmTic.cmdTac8.Caption = "X" And frmTic.cmdTac9.Caption = "X" Or frmTic.cmdTac2.Caption = "X" And frmTic.cmdTac5.Caption = "X" And frmTic.cmdTac8.Caption = "X" Or frmTic.cmdTac3.Caption = "X" And frmTic.cmdTac6.Caption = "X" And frmTic.cmdTac9.Caption = "X" Then
    MsgBox ("Congratulations X you won")
End If

If frmTic.cmdTac1.Caption = "O" And frmTic.cmdTac2.Caption = "O" And frmTic.cmdTac3.Caption = "O" Or frmTic.cmdTac1.Caption = "O" And frmTic.cmdTac4.Caption = "O" And frmTic.cmdTac7.Caption = "O" Or frmTic.cmdTac1.Caption = "O" And frmTic.cmdTac5.Caption = "O" And frmTic.cmdTac9.Caption = "O" Then
    MsgBox ("Congratulations O you won")
End If

If frmTic.cmdTac4.Caption = "O" And frmTic.cmdTac5.Caption = "O" And frmTic.cmdTac6.Caption = "O" Then
    MsgBox ("Congratulations O you won")
End If

If frmTic.cmdTac7.Caption = "O" And frmTic.cmdTac8.Caption = "O" And frmTic.cmdTac9.Caption = "O" Or frmTic.cmdTac2.Caption = "O" And frmTic.cmdTac5.Caption = "O" And frmTic.cmdTac8.Caption = "O" Or frmTic.cmdTac3.Caption = "O" And frmTic.cmdTac6.Caption = "O" And frmTic.cmdTac9.Caption = "O" Then
    MsgBox ("Congratulations O you won")
End If

If intCat = 9 Then
    MsgBox ("Sorry its a cats game")
End If
End Function


Download this snippet    Add to My Saved Code

This creates a Tic Tac toe game Comments

No comments have been posted about This creates a Tic Tac toe game. Why not be the first to post a comment about This creates a Tic Tac toe game.

Post your comment

Subject:
Message:
0/1000 characters