VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Plays TicTacToe; better then Masta's

by Brian D. (1 Submission)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 12th July 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Plays TicTacToe; better then Masta's

API Declarations


Dim D As Integer
Dim X As Integer
Dim O As Integer
Dim W As Boolean
Dim c As Integer
Dim seconds As Double
Dim test1 As Boolean
Dim test2 As Boolean
Dim test3 As Boolean
Dim test4 As Boolean
Dim test5 As Boolean
Dim test6 As Boolean
Dim test7 As Boolean
Dim test8 As Boolean
Dim test9 As Boolean

Dim D As Integer
Dim X As Integer
Dim O As Integer
Dim W As Boolean
Dim c As Integer
Dim seconds As Double
Dim test1 As Boolean
Dim test2 As Boolean
Dim test3 As Boolean
Dim test4 As Boolean
Dim test5 As Boolean
Dim test6 As Boolean
Dim test7 As Boolean
Dim test8 As Boolean
Dim test9 As Boolean

Rate Plays TicTacToe; better then Masta's



Dim rc As Long

rc = MsgBox("Are you sure you want to quit?", vbYesNo)

If rc = vbYes Then
    Unload Me
End If

End Sub

Private Sub cmdNew_Click()

Form_Load
ClearCommands
lblP1.Caption = ""
lblP2.Caption = ""
lblMessage.Caption = ""
End Sub

Private Sub comR1c1_Click()
D = D + 1

If test1 = True Then
    
    MsgBox "Already Selected!", vbOKOnly
    D = D - 1

Else

    If D Mod 2 = 1 Then
        comR1c1.Caption = "O"
        test1 = True
    Else
        comR1c1.Caption = "X"
        test1 = True

End If
comStart_Click
End If
End Sub

Private Sub comR1c2_Click()
D = D + 1

If test2 = True Then
    
    MsgBox "Already Selected!", vbOKOnly
    D = D - 1

Else
    If D Mod 2 = 1 Then
        comR1c2.Caption = "O"
        test2 = True
        
    Else
        comR1c2.Caption = "X"
        test2 = True
        
End If
comStart_Click
End If
End Sub

Private Sub comR1c3_Click()
D = D + 1
If test3 = True Then
    
    MsgBox "Already Selected!", vbOKOnly
    D = D - 1
    
Else
    If D Mod 2 = 1 Then
    comR1c3.Caption = "O"
    test3 = True
    
Else
    comR1c3.Caption = "X"
    test3 = True
    
End If
comStart_Click
End If
End Sub

Private Sub comR2c1_Click()
D = D + 1

If test4 = True Then
    
    MsgBox "Already Selected!", vbOKOnly
    D = D - 1
   
Else

    If D Mod 2 = 1 Then
    comR2c1.Caption = "O"
    test4 = True
    
Else
    comR2c1.Caption = "X"
    test4 = True
    
End If
comStart_Click
End If

End Sub

Private Sub comR2c2_Click()
D = D + 1

If test5 = True Then
    
    MsgBox "Already Selected!", vbOKOnly
    D = D - 1
    
Else

    If D Mod 2 = 1 Then
    comR2c2.Caption = "O"
    test5 = True
    
Else
    comR2c2.Caption = "X"
    test5 = True
    
End If
comStart_Click
End If

End Sub

Private Sub comR2c3_Click()
D = D + 1

If test6 = True Then
    
    MsgBox "Already Selected!", vbOKOnly
    D = D - 1
    
Else
    
    If D Mod 2 = 1 Then
    comR2c3.Caption = "O"
    test6 = True
    
Else
    comR2c3.Caption = "X"
    test6 = True
    
End If
comStart_Click
End If
End Sub

Private Sub comR3c1_Click()
D = D + 1

If test7 = True Then
    
    MsgBox "Already Selected!", vbOKOnly
    D = D - 1
    
Else

    If D Mod 2 = 1 Then
    comR3c1.Caption = "O"
    test7 = True
    
Else
    comR3c1.Caption = "X"
    test7 = True
    
End If
comStart_Click
End If
End Sub

Private Sub comR3c2_Click()
D = D + 1

If test8 = True Then
    
    MsgBox "Already Selected!", vbOKOnly
    D = D - 1
    
Else

    If D Mod 2 = 1 Then
    comR3c2.Caption = "O"
    test8 = True
    
Else
    comR3c2.Caption = "X"
    test8 = True
    
End If
comStart_Click
End If
End Sub

Private Sub comR3c3_Click()
D = D + 1

If test9 = True Then
    
    MsgBox "Already Selected!", vbOKOnly
    D = D - 1
    
Else

    If D Mod 2 = 1 Then
    comR3c3.Caption = "O"
    test9 = True
    
Else
    comR3c3.Caption = "X"
    test9 = True
    
End If
comStart_Click
End If
End Sub

Public Sub comStart_Click()

If D Mod 2 = 1 Then
    lblMessage.Caption = "Player 1 GO"
Else
    lblMessage.Caption = "Player 2 GO"
End If

If comR1c1.Caption = "X" And comR1c2.Caption = "X" And comR1c3.Caption = "X" Then
    lblMessage.Caption = "Player 1 Wins"
    X = X + 1
    lblP1.Caption = X
    W = True
    ClearCommands
ElseIf comR1c1.Caption = "X" And comR2c1.Caption = "X" And comR3c1.Caption = "X" Then
    lblMessage.Caption = "Player 1 Wins"
    X = X + 1
    lblP1.Caption = X
    W = True
    ClearCommands
ElseIf comR1c1.Caption = "X" And comR2c2.Caption = "X" And comR3c3.Caption = "X" Then
    lblMessage.Caption = "Player 1 Wins"
    X = X + 1
    lblP1.Caption = X
    W = True
    ClearCommands
ElseIf comR2c1.Caption = "X" And comR2c2.Caption = "X" And comR2c3.Caption = "X" Then
    lblMessage.Caption = "Player 1 Wins"
    X = X + 1
    lblP1.Caption = X
    W = True
    ClearCommands
ElseIf comR3c1.Caption = "X" And comR3c2.Caption = "X" And comR3c3.Caption = "X" Then
    lblMessage.Caption = "Player 1 Wins"
    X = X + 1
    lblP1.Caption = X
    W = True
    ClearCommands
ElseIf comR1c2.Caption = "X" And comR2c2.Caption = "X" And comR3c2.Caption = "X" Then
    lblMessage.Caption = "Player 1 Wins"
    X = X + 1
    lblP1.Caption = X
    W = True
    ClearCommands
ElseIf comR1c3.Caption = "X" And comR2c3.Caption = "X" And comR3c3.Caption = "X" Then
    lblMessage.Caption = "Player 1 Wins"
    X = X + 1
    lblP1.Caption = X
    W = True
    ClearCommands
ElseIf comR1c3.Caption = "X" And comR2c3.Caption = "X" And comR3c1.Caption = "X" Then
    lblMessage.Caption = "Player 1 Wins"
    X = X + 1
    lblP1.Caption = X
    W = True
    ClearCommands
ElseIf comR3c1.Caption = "X" And comR2c2.Caption = "X" And comR1c3.Caption = "X" Then
    lblMessage.Caption = "Player 1 Wins"
    X = X + 1
    lblP1.Caption = X
    W = True
    ClearCommands
ElseIf (comR1c1.Caption = "O" And comR1c2.Caption = "O" And comR1c3.Caption = "O") Then
    lblMessage.Caption = "Player 2 Wins"
    O = O + 1
    lblP2.Caption = O
    W = True
    ClearCommands
ElseIf comR1c1.Caption = "O" And comR2c1.Caption = "O" And comR3c1.Caption = "O" Then
    lblMessage.Caption = "Player 2 Wins"
    O = O + 1
    lblP2.Caption = O
    W = True
    ClearCommands
ElseIf comR1c1.Caption = "O" And comR2c2.Caption = "O" And comR3c3.Caption = "O" Then
    lblMessage.Caption = "Player 2 Wins"
    O = O + 1
    lblP2.Caption = O
    W = True
    ClearCommands
ElseIf comR2c1.Caption = "O" And comR2c2.Caption = "O" And comR2c3.Caption = "O" Then
    lblMessage.Caption = "Player 2 Wins"
    O = O + 1
    lblP2.Caption = O
    W = True
    ClearCommands
ElseIf comR3c1.Caption = "O" And comR3c2.Caption = "O" And comR3c3.Caption = "O" Then
    lblMessage.Caption = "Player 2 Wins"
    O = O + 1
    lblP2.Caption = O
    W = True
    ClearCommands
ElseIf comR1c2.Caption = "O" And comR2c2.Caption = "O" And comR3c2.Caption = "O" Then
    lblMessage.Caption = "Player 2 Wins"
    O = O + 1
    lblP2.Caption = O
    W = True
    ClearCommands
ElseIf comR1c3.Caption = "O" And comR2c3.Caption = "O" And comR3c3.Caption = "O" Then
    lblMessage.Caption = "Player 2 Wins"
    O = O + 1
    lblP2.Caption = O
    W = True
    ClearCommands
ElseIf comR1c3.Caption = "O" And comR2c3.Caption = "O" And comR3c1.Caption = "O" Then
    lblMessage.Caption = "Player 2 Wins"
    O = O + 1
    lblP2.Caption = O
    W = True
    ClearCommands
ElseIf comR3c1.Caption = "O" And comR2c2.Caption = "O" And comR1c3.Caption = "O" Then
    lblMessage.Caption = "Player 2 Wins"
    O = O + 1
    lblP2.Caption = O
    W = True
    ClearCommands
    
ElseIf D = 10 And W = False Then
    c = c + 1
    lblMessage.Caption = "CAT Wins"
    lblCat.Caption = c
    ClearCommands
    
End If
End Sub

Private Sub Form_Load()
D = 1
X = 0
O = 0
c = 0
W = False
End Sub

Public Sub ClearCommands()

    seconds = Timer
    While (Timer < seconds + 2)
    Wend
    comR1c1.Caption = " "
    comR1c2.Caption = " "
    comR1c3.Caption = " "
    comR2c1.Caption = " "
    comR2c2.Caption = " "
    comR2c3.Caption = " "
    comR3c1.Caption = " "
    comR3c2.Caption = " "
    comR3c3.Caption = " "
    D = 1
    W = False
    test1 = False
    test2 = False
    test3 = False
    test4 = False
    test5 = False
    test6 = False
    test7 = False
    test8 = False
    test9 = False
    
End Sub




Download this snippet    Add to My Saved Code

Plays TicTacToe; better then Masta's Comments

No comments have been posted about Plays TicTacToe; better then Masta's. Why not be the first to post a comment about Plays TicTacToe; better then Masta's.

Post your comment

Subject:
Message:
0/1000 characters