Need help with this college project,
1.      Create a two player Tic-Tac-Toe game using pictureboxes as the 9 possible squares (you will have to design your own graphics for the O and X in paint).  
a.      Create a sub routine called XO_Click with the appropriate click arguments.  This routine should fill the clicked picturebox with the appropriate image.
b.      Dynamically add nine pictureboxes to your form.
c.      Dynamically assign the click event for each of these picturesboxes to your XO_Click code.
here is my code so far...

Am I i in the right track....
Public Class FrmMain
    Private Const intNumSpaces As Int16 = 9
    Private Const intSpacePerRow As Int16 = 3
    Private Const intxHeight As Int16 = 122
    Private Const intxWidth As Int16 = 115
    Private Const intMargin As Int16 = 20
    Private Const intLabelHeight As Int16 = 23
    Private titleBarHeight As Int16
    Private Sub FrmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim intBorderWidth As Int16 = (Me.Width - Me.ClientSize.Width) / 2
        titleBarHeight = Me.Height - Me.ClientSize.Height - 2 * intBorderWidth
        'set height and width of form
        Me.Height = Math.Ceiling(intNumSpaces / intSpacePerRow) * (intxHeight _
                    + intLabelHeight) + intMargin + titleBarHeight + 2 * intBorderWidth
        Me.Width = intSpacePerRow * (intxWidth + intLabelHeight) + intMargin + 2 * intBorderWidth
        'center form
        Me.Left = (My.Computer.Screen.WorkingArea.Width - Me.Width) / 2
        Me.Top = (My.Computer.Screen.WorkingArea.Height - Me.Height) / 2
        Dim i As Int16
        'loop through chairs
        For i = 0 To intNumSpaces - 1
            Dim seat As New PictureBox
            seat.Parent = Me
            seat.Left = (i Mod intSpacePerRow) * (intxWidth + intLabelHeight) + intMargin
            seat.Top = (i \ intSpacePerRow) * (intxHeight + intLabelHeight) + intMargin
            seat.Height = intxHeight
            seat.Width = intxWidth
            seat.Image = Image.FromFile("..\..\images\x.jpg")
            seat.Name = (i + 1).ToString
            seat.Tag = ""
    End Sub
    Private Sub XO_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim p As PictureBox
        p = CType(sender, PictureBox)
    End Sub
End Class

Open in new window

Who is Participating?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.