[Help] Tic-Tac-Toe

Posts 1–12 of 12 · Page 1 of 1
[Help] Tic-Tac-Toe
Hey i found some codes for Tic Tac Toe but i am getting error pls help me:
code:
Code:
Public Class tictactoe
    Inherits System.Windows.Forms.Form
    Dim p As New Integer
    Dim pic As New PictureBox
#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents tside As System.Windows.Forms.Label
    Friend WithEvents lside As System.Windows.Forms.Label
    Friend WithEvents rside As System.Windows.Forms.Label
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents x As System.Windows.Forms.PictureBox
    Friend WithEvents o As System.Windows.Forms.PictureBox
    Friend WithEvents Wplayer As System.Windows.Forms.Label
    Friend WithEvents Start As System.Windows.Forms.Button
    Friend WithEvents pic1 As System.Windows.Forms.PictureBox
    Friend WithEvents pic2 As System.Windows.Forms.PictureBox
    Friend WithEvents pic9 As System.Windows.Forms.PictureBox
    Friend WithEvents pic8 As System.Windows.Forms.PictureBox
    Friend WithEvents pic7 As System.Windows.Forms.PictureBox
    Friend WithEvents pic6 As System.Windows.Forms.PictureBox
    Friend WithEvents pic5 As System.Windows.Forms.PictureBox
    Friend WithEvents pic4 As System.Windows.Forms.PictureBox
    Friend WithEvents pic3 As System.Windows.Forms.PictureBox
    Friend WithEvents Closer As System.Windows.Forms.Button
    Friend WithEvents blank As System.Windows.Forms.PictureBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(tictactoe))
        Me.tside = New System.Windows.Forms.Label
        Me.lside = New System.Windows.Forms.Label
        Me.rside = New System.Windows.Forms.Label
        Me.Label1 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.Label3 = New System.Windows.Forms.Label
        Me.Label4 = New System.Windows.Forms.Label
        Me.Label5 = New System.Windows.Forms.Label
        Me.pic1 = New System.Windows.Forms.PictureBox
        Me.pic2 = New System.Windows.Forms.PictureBox
        Me.pic9 = New System.Windows.Forms.PictureBox
        Me.pic8 = New System.Windows.Forms.PictureBox
        Me.pic7 = New System.Windows.Forms.PictureBox
        Me.pic6 = New System.Windows.Forms.PictureBox
        Me.pic5 = New System.Windows.Forms.PictureBox
        Me.pic4 = New System.Windows.Forms.PictureBox
        Me.pic3 = New System.Windows.Forms.PictureBox
        Me.x = New System.Windows.Forms.PictureBox
        Me.o = New System.Windows.Forms.PictureBox
        Me.Wplayer = New System.Windows.Forms.Label
        Me.Start = New System.Windows.Forms.Button
        Me.Closer = New System.Windows.Forms.Button
        Me.blank = New System.Windows.Forms.PictureBox
        Me.SuspendLayout()
        '
        'tside
        '
        Me.tside.BackColor = System.Drawing.Color.Black
        Me.tside.Location = New System.Drawing.Point(8, 8)
        Me.tside.Name = "tside"
        Me.tside.Size = New System.Drawing.Size(150, 1)
        Me.tside.TabIndex = 0
        '
        'lside
        '
        Me.lside.BackColor = System.Drawing.Color.Black
        Me.lside.Location = New System.Drawing.Point(8, 8)
        Me.lside.Name = "lside"
        Me.lside.Size = New System.Drawing.Size(1, 150)
        Me.lside.TabIndex = 1
        '
        'rside
        '
        Me.rside.BackColor = System.Drawing.Color.Black
        Me.rside.Location = New System.Drawing.Point(157, 8)
        Me.rside.Name = "rside"
        Me.rside.Size = New System.Drawing.Size(1, 150)
        Me.rside.TabIndex = 2
        '
        'Label1
        '
        Me.Label1.BackColor = System.Drawing.Color.Black
        Me.Label1.Location = New System.Drawing.Point(8, 157)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(150, 1)
        Me.Label1.TabIndex = 3
        '
        'Label2
        '
        Me.Label2.BackColor = System.Drawing.Color.Black
        Me.Label2.Location = New System.Drawing.Point(57, 8)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(1, 150)
        Me.Label2.TabIndex = 4
        '
        'Label3
        '
        Me.Label3.BackColor = System.Drawing.Color.Black
        Me.Label3.Location = New System.Drawing.Point(106, 8)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(1, 150)
        Me.Label3.TabIndex = 5
        '
        'Label4
        '
        Me.Label4.BackColor = System.Drawing.Color.Black
        Me.Label4.Location = New System.Drawing.Point(8, 57)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(150, 1)
        Me.Label4.TabIndex = 6
        '
        'Label5
        '
        Me.Label5.BackColor = System.Drawing.Color.Black
        Me.Label5.Location = New System.Drawing.Point(8, 106)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(150, 1)
        Me.Label5.TabIndex = 7
        '
        'pic1
        '
        Me.pic1.Location = New System.Drawing.Point(16, 16)
        Me.pic1.Name = "pic1"
        Me.pic1.Size = New System.Drawing.Size(32, 32)
        Me.pic1.TabIndex = 8
        Me.pic1.TabStop = False
        '
        'pic2
        '
        Me.pic2.Location = New System.Drawing.Point(64, 16)
        Me.pic2.Name = "pic2"
        Me.pic2.Size = New System.Drawing.Size(32, 32)
        Me.pic2.TabIndex = 9
        Me.pic2.TabStop = False
        '
        'pic9
        '
        Me.pic9.Location = New System.Drawing.Point(112, 112)
        Me.pic9.Name = "pic9"
        Me.pic9.Size = New System.Drawing.Size(32, 32)
        Me.pic9.TabIndex = 10
        Me.pic9.TabStop = False
        '
        'pic8
        '
        Me.pic8.Location = New System.Drawing.Point(64, 112)
        Me.pic8.Name = "pic8"
        Me.pic8.Size = New System.Drawing.Size(32, 32)
        Me.pic8.TabIndex = 11
        Me.pic8.TabStop = False
        '
        'pic7
        '
        Me.pic7.Location = New System.Drawing.Point(16, 112)
        Me.pic7.Name = "pic7"
        Me.pic7.Size = New System.Drawing.Size(32, 32)
        Me.pic7.TabIndex = 12
        Me.pic7.TabStop = False
        '
        'pic6
        '
        Me.pic6.Location = New System.Drawing.Point(112, 64)
        Me.pic6.Name = "pic6"
        Me.pic6.Size = New System.Drawing.Size(32, 32)
        Me.pic6.TabIndex = 13
        Me.pic6.TabStop = False
        '
        'pic5
        '
        Me.pic5.Location = New System.Drawing.Point(64, 64)
        Me.pic5.Name = "pic5"
        Me.pic5.Size = New System.Drawing.Size(32, 32)
        Me.pic5.TabIndex = 14
        Me.pic5.TabStop = False
        '
        'pic4
        '
        Me.pic4.Location = New System.Drawing.Point(16, 64)
        Me.pic4.Name = "pic4"
        Me.pic4.Size = New System.Drawing.Size(32, 32)
        Me.pic4.TabIndex = 15
        Me.pic4.TabStop = False
        '
        'pic3
        '
        Me.pic3.Location = New System.Drawing.Point(112, 16)
        Me.pic3.Name = "pic3"
        Me.pic3.Size = New System.Drawing.Size(32, 32)
        Me.pic3.TabIndex = 16
        Me.pic3.TabStop = False
        '
        'x
        '
        Me.x.Image = CType(resources.GetObject("x.Image"), System.Drawing.Image)
        Me.x.Location = New System.Drawing.Point(16, 168)
        Me.x.Name = "x"
        Me.x.Size = New System.Drawing.Size(8, 16)
        Me.x.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
        Me.x.TabIndex = 17
        Me.x.TabStop = False
        Me.x.Visible = False
        '
        'o
        '
        Me.o.Image = CType(resources.GetObject("o.Image"), System.Drawing.Image)
        Me.o.Location = New System.Drawing.Point(40, 168)
        Me.o.Name = "o"
        Me.o.Size = New System.Drawing.Size(8, 16)
        Me.o.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
        Me.o.TabIndex = 18
        Me.o.TabStop = False
        Me.o.Visible = False
        '
        'Wplayer
        '
        Me.Wplayer.Location = New System.Drawing.Point(192, 16)
        Me.Wplayer.Name = "Wplayer"
        Me.Wplayer.Size = New System.Drawing.Size(88, 16)
        Me.Wplayer.TabIndex = 19
        Me.Wplayer.Text = "Player X"
        '
        'Start
        '
        Me.Start.Location = New System.Drawing.Point(184, 56)
        Me.Start.Name = "Start"
        Me.Start.TabIndex = 20
        Me.Start.Tag = ""
        Me.Start.Text = "New Game"
        '
        'Closer
        '
        Me.Closer.Location = New System.Drawing.Point(184, 104)
        Me.Closer.Name = "Closer"
        Me.Closer.TabIndex = 21
        Me.Closer.Text = "Exit"
        '
        'blank
        '
        Me.blank.Location = New System.Drawing.Point(64, 176)
        Me.blank.Name = "blank"
        Me.blank.Size = New System.Drawing.Size(8, 8)
        Me.blank.TabIndex = 22
        Me.blank.TabStop = False
        '
        'tictactoe
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.BackColor = System.Drawing.Color.Red
        Me.ClientSize = New System.Drawing.Size(292, 166)
        Me.Controls.Add(Me.blank)
        Me.Controls.Add(Me.Closer)
        Me.Controls.Add(Me.Start)
        Me.Controls.Add(Me.Wplayer)
        Me.Controls.Add(Me.o)
        Me.Controls.Add(Me.x)
        Me.Controls.Add(Me.pic3)
        Me.Controls.Add(Me.pic4)
        Me.Controls.Add(Me.pic5)
        Me.Controls.Add(Me.pic6)
        Me.Controls.Add(Me.pic7)
        Me.Controls.Add(Me.pic8)
        Me.Controls.Add(Me.pic9)
        Me.Controls.Add(Me.pic2)
        Me.Controls.Add(Me.pic1)
        Me.Controls.Add(Me.Label5)
        Me.Controls.Add(Me.Label4)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.rside)
        Me.Controls.Add(Me.lside)
        Me.Controls.Add(Me.tside)
        Me.Name = "tictactoe"
        Me.Text = "Tic-Tac-Toe"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub tictactoe_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        p = 1
    End Sub

    Private Sub pic_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pic1.Click, pic2.Click, pic3.Click, pic4.Click, pic5.Click, pic6.Click, pic7.Click, pic8.Click, pic9.Click
        pic = sender
        Select Case p
            Case 1
                If pic.Image Is blank.Image Then
                    p = 2
                    Wplayer.Text = "Player O"
                    pic.Image = x.Image
                End If
            Case 2
                If pic.Image Is blank.Image Then
                    p = 1
                    Wplayer.Text = "Player X"
                    pic.Image = o.Image
                End If
        End Select
        Call win()
        Call tie()
        Call win3()
    End Sub

    Private Sub Closer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Closer.Click
        End
    End Sub

    Private Sub Start_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Start.Click
        pic1.Image = blank.Image
        pic2.Image = blank.Image
        pic3.Image = blank.Image
        pic4.Image = blank.Image
        pic5.Image = blank.Image
        pic6.Image = blank.Image
        pic7.Image = blank.Image
        pic8.Image = blank.Image
        pic9.Image = blank.Image
        pic1.Enabled = True
        pic2.Enabled = True
        pic3.Enabled = True
        pic4.Enabled = True
        pic5.Enabled = True
        pic6.Enabled = True
        pic7.Enabled = True
        pic8.Enabled = True
        pic9.Enabled = True
        Wplayer.Text = "Player X"
        p = 1
    End Sub
    Public Function win()
        If pic1.Image Is pic2.Image And pic2.Image Is pic3.Image And pic3.Image Is x.Image Then
            Call win2()
        End If
        If pic4.Image Is pic5.Image And pic5.Image Is pic6.Image And pic6.Image Is x.Image Then
            Call win2()
        End If
        If pic7.Image Is pic8.Image And pic8.Image Is pic9.Image And pic9.Image Is x.Image Then
            Call win2()
        End If
        If pic1.Image Is pic4.Image And pic4.Image Is pic7.Image And pic7.Image Is x.Image Then
            Call win2()
        End If
        If pic2.Image Is pic5.Image And pic5.Image Is pic8.Image And pic8.Image Is x.Image Then
            Call win2()
        End If
        If pic3.Image Is pic6.Image And pic6.Image Is pic9.Image And pic9.Image Is x.Image Then
            Call win2()
        End If
        If pic3.Image Is pic5.Image And pic5.Image Is pic7.Image And pic7.Image Is x.Image Then
            Call win2()
        End If
        If pic1.Image Is pic5.Image And pic5.Image Is pic9.Image And pic9.Image Is x.Image Then
            Call win2()
        End If
    End Function
    Public Function win2()
        pic1.Enabled = False
        pic2.Enabled = False
        pic3.Enabled = False
        pic4.Enabled = False
        pic5.Enabled = False
        pic6.Enabled = False
        pic7.Enabled = False
        pic8.Enabled = False
        pic9.Enabled = False
        If p = 1 Then
            Wplayer.Text = "Player O WINS!"
        Else
            Wplayer.Text = "Player X WINS!"
        End If
    End Function
    Public Function tie()
        If pic1.Image Is blank.Image Then
        ElseIf pic2.Image Is blank.Image Then
        ElseIf pic3.Image Is blank.Image Then
        ElseIf pic4.Image Is blank.Image Then
        ElseIf pic5.Image Is blank.Image Then
        ElseIf pic6.Image Is blank.Image Then
        ElseIf pic7.Image Is blank.Image Then
        ElseIf pic8.Image Is blank.Image Then
        ElseIf pic9.Image Is blank.Image Then
        Else
            pic1.Enabled = False
            pic2.Enabled = False
            pic3.Enabled = False
            pic4.Enabled = False
            pic5.Enabled = False
            pic6.Enabled = False
            pic7.Enabled = False
            pic8.Enabled = False
            pic9.Enabled = False
            Wplayer.Text = "TIE!"
        End If
    End Function
    Public Function win3()
        If pic1.Image Is pic2.Image And pic2.Image Is pic3.Image And pic3.Image Is o.Image Then
            Call win2()
        End If
        If pic4.Image Is pic5.Image And pic5.Image Is pic6.Image And pic6.Image Is o.Image Then
            Call win2()
        End If
        If pic7.Image Is pic8.Image And pic8.Image Is pic9.Image And pic9.Image Is o.Image Then
            Call win2()
        End If
        If pic1.Image Is pic4.Image And pic4.Image Is pic7.Image And pic7.Image Is o.Image Then
            Call win2()
        End If
        If pic2.Image Is pic5.Image And pic5.Image Is pic8.Image And pic8.Image Is o.Image Then
            Call win2()
        End If
        If pic3.Image Is pic6.Image And pic6.Image Is pic9.Image And pic9.Image Is o.Image Then
            Call win2()
        End If
        If pic3.Image Is pic5.Image And pic5.Image Is pic7.Image And pic7.Image Is o.Image Then
            Call win2()
        End If
        If pic1.Image Is pic5.Image And pic5.Image Is pic9.Image And pic9.Image Is o.Image Then
            Call win2()
        End If
    End Function
End Class
copy & paste doesn't work...........

here is a SS what must i do
All your errors are duplicate code related, go into you code and rmeove and duplicate declarations and subs
thats what happens when you just copy and paste.
yea. exactly what nextgen1 said. lol ^_^

i had the same problem with the same exact program...

Let me guess... the tic-tac-toe program is off of youtube? lol
those youtube vids usually dont work
Quote Originally Posted by zmansquared View Post
those youtube vids usually dont work
If you follow every step from the video and write everything from your hand it works other if you C&P it doesnt work(most of the times)
I dont copy and paste, i write the code to actually learn fromthe tutorial XD
ya i guess your right hejsan. i meant just lick ctrl c then crtl v from the code on the side
Follow tutorials correctly, and fix up your GUI, colored buttons really plague me. :/
Quote Originally Posted by tempta43 View Post
Follow tutorials correctly, and fix up your GUI, colored buttons really plague me. :/
Seriously...

So does red. lol
Posts 1–12 of 12 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us