VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   3195
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3195
   ScaleWidth      =   4680
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton quit 
      Caption         =   "&Quit"
      Height          =   495
      Left            =   2640
      TabIndex        =   1
      Top             =   1440
      Width           =   1215
   End
   Begin VB.CommandButton clear 
      Caption         =   "&Clear"
      Height          =   495
      Left            =   2640
      TabIndex        =   0
      Top             =   600
      Width           =   1215
   End
   Begin VB.Label Label1 
      BackColor       =   &H00FF0000&
      ForeColor       =   &H00FFFF00&
      Height          =   495
      Index           =   9
      Left            =   1680
      TabIndex        =   10
      Top             =   1800
      Width           =   495
   End
   Begin VB.Label Label1 
      BackColor       =   &H00FF0000&
      ForeColor       =   &H00FFFF00&
      Height          =   495
      Index           =   8
      Left            =   960
      TabIndex        =   9
      Top             =   1800
      Width           =   495
   End
   Begin VB.Label Label1 
      BackColor       =   &H00FF0000&
      ForeColor       =   &H00FFFF00&
      Height          =   495
      Index           =   7
      Left            =   240
      TabIndex        =   8
      Top             =   1800
      Width           =   495
   End
   Begin VB.Label Label1 
      BackColor       =   &H00FF0000&
      ForeColor       =   &H00FFFF00&
      Height          =   495
      Index           =   6
      Left            =   1680
      TabIndex        =   7
      Top             =   1080
      Width           =   495
   End
   Begin VB.Label Label1 
      BackColor       =   &H00FF0000&
      ForeColor       =   &H00FFFF00&
      Height          =   495
      Index           =   5
      Left            =   960
      TabIndex        =   6
      Top             =   1080
      Width           =   495
   End
   Begin VB.Label Label1 
      BackColor       =   &H00FF0000&
      ForeColor       =   &H00FFFF00&
      Height          =   495
      Index           =   4
      Left            =   240
      TabIndex        =   5
      Top             =   1080
      Width           =   495
   End
   Begin VB.Label Label1 
      BackColor       =   &H00FF0000&
      ForeColor       =   &H00FFFF00&
      Height          =   495
      Index           =   3
      Left            =   1680
      TabIndex        =   4
      Top             =   360
      Width           =   495
   End
   Begin VB.Label Label1 
      BackColor       =   &H00FF0000&
      ForeColor       =   &H00FFFF00&
      Height          =   495
      Index           =   2
      Left            =   960
      TabIndex        =   3
      Top             =   360
      Width           =   495
   End
   Begin VB.Label Label1 
      BackColor       =   &H00FF0000&
      ForeColor       =   &H00FFFF00&
      Height          =   495
      Index           =   1
      Left            =   240
      TabIndex        =   2
      Top             =   360
      Width           =   495
   End
   Begin VB.Line Line4 
      X1              =   120
      X2              =   2280
      Y1              =   1680
      Y2              =   1680
   End
   Begin VB.Line Line3 
      X1              =   120
      X2              =   2280
      Y1              =   960
      Y2              =   960
   End
   Begin VB.Line Line2 
      X1              =   1560
      X2              =   1560
      Y1              =   240
      Y2              =   2520
   End
   Begin VB.Line Line1 
      X1              =   840
      X2              =   840
      Y1              =   240
      Y2              =   2520
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim player As Boolean
Dim winner As Boolean

Private Sub clear_Click()
Label1(1) = ""
Label1(2) = ""
Label1(3) = ""
Label1(4) = ""
Label1(5) = ""
Label1(6) = ""
Label1(7) = ""
Label1(8) = ""
Label1(9) = ""
player = True
winner = False
End Sub

Private Sub Form_Load()
player = True
winner = False
End Sub
'SINCE THE LABEL IS IN AN ARRAY IT SENSES A CLICK ON ANY OF THEM
'AND ASSIGNS THE LABEL NUMBER AS INDEX
Private Sub Label1_Click(Index As Integer)
If player = True Then
    If Label1(Index).Caption = "" Then
        Label1(Index).Caption = "X"
        player = False
    End If
    If Label1(Index).Caption = "O" Then
        MsgBox "Illegal Move"
    End If

Else
    If Label1(Index).Caption = "" Then
        Label1(Index).Caption = "O"
        player = True
    End If
    If Label1(Index).Caption = "X" Then
        MsgBox "Illegal Move"
    End If
End If
Call checkwin

End Sub

Private Sub quit_Click()
Unload Me
'Shawn's easier to understand version of Tic-Tac-Toe
End Sub
Private Sub checkwin()

If Label1(1) = "X" And Label1(2) = "X" And Label1(3) = "X" Then
MsgBox "The Winner is X!"
winner = True
End If
If Label1(1) = "X" And Label1(4) = "X" And Label1(7) = "X" Then
MsgBox "The Winner is X!"
winner = True
End If
If Label1(1) = "X" And Label1(5) = "X" And Label1(9) = "X" Then
MsgBox "The Winner is X!"
winner = True
End If
If Label1(4) = "X" And Label1(5) = "X" And Label1(6) = "X" Then
MsgBox "The Winner is X!"
winner = True
End If
If Label1(7) = "X" And Label1(8) = "X" And Label1(9) = "X" Then
MsgBox "The Winner is X!"
winner = True
End If
If Label1(7) = "X" And Label1(5) = "X" And Label1(3) = "X" Then
MsgBox "The Winner is X!"
winner = True
End If
If Label1(2) = "X" And Label1(5) = "X" And Label1(8) = "X" Then
MsgBox "The Winner is X!"
winner = True
End If
If Label1(3) = "X" And Label1(6) = "X" And Label1(9) = "X" Then
MsgBox "The Winner is X!"
winner = True
End If

If Label1(1) = "O" And Label1(2) = "O" And Label1(3) = "O" Then
MsgBox "The Winner is O!"
winner = True
End If
If Label1(1) = "O" And Label1(4) = "O" And Label1(7) = "O" Then
MsgBox "The Winner is O!"
winner = True
End If
If Label1(1) = "O" And Label1(5) = "O" And Label1(9) = "O" Then
MsgBox "The Winner is O!"
winner = True
End If
If Label1(4) = "O" And Label1(5) = "O" And Label1(6) = "O" Then
MsgBox "The Winner is O!"
winner = True
End If
If Label1(7) = "O" And Label1(8) = "O" And Label1(9) = "O" Then
MsgBox "The Winner is O!"
winner = True
End If
If Label1(7) = "O" And Label1(5) = "O" And Label1(3) = "O" Then
MsgBox "The Winner is O!"
winner = True
End If
If Label1(2) = "O" And Label1(5) = "O" And Label1(8) = "O" Then
MsgBox "The Winner is O!"
winner = True
End If
If Label1(3) = "O" And Label1(6) = "O" And Label1(9) = "O" Then
MsgBox "The Winner is O!"
winner = True
End If

If Label1(1) <> "" And Label1(2) <> "" And Label1(3) <> "" And Label1(4) <> "" And Label1(5) <> "" And Label1(6) <> "" And Label1(7) <> "" And Label1(8) <> "" And Label1(9) <> "" And winner = False Then
MsgBox "The Game is a Tie!"
End If

End Sub
