~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Option Strict Off
Option Explicit On
Friend Class frmTicTacToe
Inherits System.Windows.Forms.Form
#Region "Windows Form Designer generated code "
Friend Enum YPoint As Short
TopSide = 35
FirstRow = 57
SecondRow = 85
ThirdRow = 119
BottomSide = 145
End Enum
Friend Enum XPoint As Short
LeftSide = 20
FirstCol = 40
SecondCol = 72
ThirdCol = 104
RightSide = 125
End Enum
' coordinates for the symbol to be drawn
Dim horiz As Short
Dim vert As Short
' Form property to show when form is initializing
Private m_IsInitializing As Boolean = True
Public Property IsInitializing() As Boolean
Get
Return m_IsInitializing
End Get
Set(ByVal Value As Boolean)
m_IsInitializing = Value
End Set
End Property
' Scoring arrays
' These are added to determine when
' a player has won
Dim iXPos(3, 3) As Short
Dim iOPos(3, 3) As Short
' Determines who plays next AND
' Used as boolean test variable
Dim sPlaySign As String
' Keeps track of played moves
Dim iPlayground(8) As Short
' Counts the number of moves
Dim iMove As Short
' Scoreboard variables
Dim iXScore As Short
Dim iOScore As Short
' Get ready to play another game
Sub InitPlayGround()
Dim i As Short
Dim j As Short
' Erase any playing grid symbols
Invalidate()
For i = 0 To 8
iPlayground(i) = -1
Next
For i = 1 To 3
For j = 1 To 3
iXPos(i, j) = 0
iOPos(i, j) = 0
Next j
Next i
' Set the next player to the appropriate sign
If optOPlayer.Checked = True Then
sPlaySign = "O"
Else
sPlaySign = "X"
End If
' Change form property to show that initialization is complete
frmTicTacToe.DefInstance.IsInitializing = False
' Number of moves so far is zero
iMove = 0
' The game isn't started until a player
' clicks the playing grid
' Display the label, not the command button
cmdNewGame.Visible = False
End Sub
~~~~~~~~~~~~~~~~~~~~~~~~~~~~