HELP MY HEAD HURTS (code problem)
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
5 posts
Page 1 of 1
Hello as some may have noticed I'm making a little game for my class in work
were learning about Egypt and well this is a game they used to play back all
those years ago
anyway I have built this game maybe 6 times now and still cant get it to work
this is the clossest I have got.
My problem is that it works for player1 (X's) but not for player2 (0's) yet the code
is EXACTLY the same for both of them.
Anyway here is the code and download the the full source if anyone could help fix this
ASAP I would be really thank full as my good friend visualtech is going to be amazing and
port it to work on ios so I can put it on the ipads in my class as well


This file is hosted off-site.
were learning about Egypt and well this is a game they used to play back all
those years ago

anyway I have built this game maybe 6 times now and still cant get it to work
this is the clossest I have got.
My problem is that it works for player1 (X's) but not for player2 (0's) yet the code
is EXACTLY the same for both of them.
Anyway here is the code and download the the full source if anyone could help fix this
ASAP I would be really thank full as my good friend visualtech is going to be amazing and
port it to work on ios so I can put it on the ipads in my class as well

Code: Select all
Public Class Seegan
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
Me.Close()
End Sub
Private Sub PictureBox1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseEnter
PictureBox1.Image = My.Resources.X_Hover
End Sub
Private Sub PictureBox1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseLeave
PictureBox1.Image = My.Resources.X
End Sub
#Region "Parts Controllers"
Dim P As New Point
Private Sub PictureBox_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)
P = e.Location
End Sub
Private Sub PictureBox_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs)
If e.Button = MouseButtons.Left Then
sender.Location = New Point(sender.Location.X + (e.X - P.X), sender.Location.Y + (e.Y - P.Y))
End If
End Sub
#End Region
Private Sub Panel1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseDown
P = e.Location
End Sub
Private Sub Panel1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseMove
If e.Button = MouseButtons.Left Then
Me.Location = New Point(MousePosition)
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim form As New Seegan
form.Show()
Me.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
MsgBox("Leader board is currently not active)")
End Sub
Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click
btn1.Image = Nothing
btn1.Tag = Nothing
If btn1.BackColor = Color.Red Then
If lbl1.Text = "It is X's Move =)" Then
btn1.Image = My.Resources.X
btn1.Tag = "1"
lbl1.Text = "It is 0's Move =)"
btn1.BackColor = Color.Transparent
btn2.BackColor = Color.Transparent
btn3.BackColor = Color.Transparent
btn4.BackColor = Color.Transparent
btn5.BackColor = Color.Transparent
btn6.BackColor = Color.Transparent
btn7.BackColor = Color.Transparent
btn8.BackColor = Color.Transparent
btn9.BackColor = Color.Transparent
Else
If btn2.Tag = Nothing Then
btn2.BackColor = Color.Red
End If
If btn4.Tag = Nothing Then
btn4.BackColor = Color.Red
End If
If btn5.Tag = Nothing Then
btn5.BackColor = Color.Red
End If
End If
ElseIf lbl1.Text = "It is 0's Move =)" Then
btn1.Image = My.Resources._0
btn1.Tag = "1"
lbl1.Text = "It is X's Move =)"
btn1.BackColor = Color.Transparent
btn2.BackColor = Color.Transparent
btn3.BackColor = Color.Transparent
btn4.BackColor = Color.Transparent
btn5.BackColor = Color.Transparent
btn6.BackColor = Color.Transparent
btn7.BackColor = Color.Transparent
btn8.BackColor = Color.Transparent
btn9.BackColor = Color.Transparent
Else
If btn2.Tag = Nothing Then
btn2.BackColor = Color.Red
End If
If btn4.Tag = Nothing Then
btn4.BackColor = Color.Red
End If
If btn5.Tag = Nothing Then
btn5.BackColor = Color.Red
End If
End If
End Sub
Private Sub btn2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn2.Click
btn2.Image = Nothing
btn2.Tag = Nothing
If btn2.BackColor = Color.Red Then
If lbl1.Text = "It is X's Move =)" Then
btn2.Image = My.Resources.X
btn2.Tag = "1"
lbl1.Text = "It is 0's Move =)"
btn1.BackColor = Color.Transparent
btn2.BackColor = Color.Transparent
btn3.BackColor = Color.Transparent
btn4.BackColor = Color.Transparent
btn5.BackColor = Color.Transparent
btn6.BackColor = Color.Transparent
btn7.BackColor = Color.Transparent
btn8.BackColor = Color.Transparent
btn9.BackColor = Color.Transparent
Else
If btn1.Tag = Nothing Then
btn1.BackColor = Color.Red
End If
If btn3.Tag = Nothing Then
btn3.BackColor = Color.Red
End If
If btn5.Tag = Nothing Then
btn5.BackColor = Color.Red
End If
If btn4.Tag = Nothing Then
btn4.BackColor = Color.Red
End If
If btn6.Tag = Nothing Then
btn6.BackColor = Color.Red
End If
End If
ElseIf lbl1.Text = "It is 0's Move =)" Then
btn2.Image = My.Resources._0
btn2.Tag = "1"
lbl1.Text = "It is X's Move =)"
btn1.BackColor = Color.Transparent
btn2.BackColor = Color.Transparent
btn3.BackColor = Color.Transparent
btn4.BackColor = Color.Transparent
btn5.BackColor = Color.Transparent
btn6.BackColor = Color.Transparent
btn7.BackColor = Color.Transparent
btn8.BackColor = Color.Transparent
btn9.BackColor = Color.Transparent
Else
If btn1.Tag = Nothing Then
btn1.BackColor = Color.Red
End If
If btn3.Tag = Nothing Then
btn3.BackColor = Color.Red
End If
If btn5.Tag = Nothing Then
btn5.BackColor = Color.Red
End If
If btn4.Tag = Nothing Then
btn4.BackColor = Color.Red
End If
If btn6.Tag = Nothing Then
btn6.BackColor = Color.Red
End If
End If
End Sub
Private Sub btn3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn3.Click
btn3.Image = Nothing
btn3.Tag = Nothing
If btn3.BackColor = Color.Red Then
If lbl1.Text = "It is X's Move =)" Then
btn3.Image = My.Resources.X
btn3.Tag = "1"
lbl1.Text = "It is 0's Move =)"
btn1.BackColor = Color.Transparent
btn2.BackColor = Color.Transparent
btn3.BackColor = Color.Transparent
btn4.BackColor = Color.Transparent
btn5.BackColor = Color.Transparent
btn6.BackColor = Color.Transparent
btn7.BackColor = Color.Transparent
btn8.BackColor = Color.Transparent
btn9.BackColor = Color.Transparent
Else
If btn2.Tag = Nothing Then
btn2.BackColor = Color.Red
End If
If btn5.Tag = Nothing Then
btn5.BackColor = Color.Red
End If
If btn6.Tag = Nothing Then
btn6.BackColor = Color.Red
End If
End If
ElseIf lbl1.Text = "It is 0's Move =)" Then
btn3.Image = My.Resources._0
btn3.Tag = "1"
lbl1.Text = "It is X's Move =)"
btn1.BackColor = Color.Transparent
btn2.BackColor = Color.Transparent
btn3.BackColor = Color.Transparent
btn4.BackColor = Color.Transparent
btn5.BackColor = Color.Transparent
btn6.BackColor = Color.Transparent
btn7.BackColor = Color.Transparent
btn8.BackColor = Color.Transparent
btn9.BackColor = Color.Transparent
Else
If btn2.Tag = Nothing Then
btn2.BackColor = Color.Red
End If
If btn5.Tag = Nothing Then
btn5.BackColor = Color.Red
End If
If btn6.Tag = Nothing Then
btn6.BackColor = Color.Red
End If
End If
End Sub
Private Sub btn4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn4.Click
btn4.Image = Nothing
btn4.Tag = Nothing
If btn4.BackColor = Color.Red Then
If lbl1.Text = "It is X's Move =)" Then
btn4.Image = My.Resources.X
btn4.Tag = "1"
lbl1.Text = "It is 0's Move =)"
btn1.BackColor = Color.Transparent
btn2.BackColor = Color.Transparent
btn3.BackColor = Color.Transparent
btn4.BackColor = Color.Transparent
btn5.BackColor = Color.Transparent
btn6.BackColor = Color.Transparent
btn7.BackColor = Color.Transparent
btn8.BackColor = Color.Transparent
btn9.BackColor = Color.Transparent
Else
If btn1.Tag = Nothing Then
btn1.BackColor = Color.Red
End If
If btn2.Tag = Nothing Then
btn2.BackColor = Color.Red
End If
If btn5.Tag = Nothing Then
btn5.BackColor = Color.Red
End If
If btn7.Tag = Nothing Then
btn7.BackColor = Color.Red
End If
If btn8.Tag = Nothing Then
btn8.BackColor = Color.Red
End If
End If
ElseIf lbl1.Text = "It is 0's Move =)" Then
btn4.Image = My.Resources._0
btn4.Tag = "1"
lbl1.Text = "It is X's Move =)"
btn1.BackColor = Color.Transparent
btn2.BackColor = Color.Transparent
btn3.BackColor = Color.Transparent
btn4.BackColor = Color.Transparent
btn5.BackColor = Color.Transparent
btn6.BackColor = Color.Transparent
btn7.BackColor = Color.Transparent
btn8.BackColor = Color.Transparent
btn9.BackColor = Color.Transparent
Else
If btn1.Tag = Nothing Then
btn1.BackColor = Color.Red
End If
If btn2.Tag = Nothing Then
btn2.BackColor = Color.Red
End If
If btn5.Tag = Nothing Then
btn5.BackColor = Color.Red
End If
If btn7.Tag = Nothing Then
btn7.BackColor = Color.Red
End If
If btn8.Tag = Nothing Then
btn8.BackColor = Color.Red
End If
End If
End Sub
Private Sub btn5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn5.Click
btn5.Image = Nothing
btn5.Tag = Nothing
If btn5.BackColor = Color.Red Then
If lbl1.Text = "It is X's Move =)" Then
btn5.Image = My.Resources.X
btn5.Tag = "1"
lbl1.Text = "It is 0's Move =)"
btn1.BackColor = Color.Transparent
btn2.BackColor = Color.Transparent
btn3.BackColor = Color.Transparent
btn4.BackColor = Color.Transparent
btn5.BackColor = Color.Transparent
btn6.BackColor = Color.Transparent
btn7.BackColor = Color.Transparent
btn8.BackColor = Color.Transparent
btn9.BackColor = Color.Transparent
Else
If btn1.Tag = Nothing Then
btn1.BackColor = Color.Red
End If
If btn2.Tag = Nothing Then
btn2.BackColor = Color.Red
End If
If btn3.Tag = Nothing Then
btn3.BackColor = Color.Red
End If
If btn4.Tag = Nothing Then
btn4.BackColor = Color.Red
End If
If btn6.Tag = Nothing Then
btn6.BackColor = Color.Red
End If
If btn7.Tag = Nothing Then
btn7.BackColor = Color.Red
End If
If btn8.Tag = Nothing Then
btn8.BackColor = Color.Red
End If
If btn9.Tag = Nothing Then
btn9.BackColor = Color.Red
End If
End If
ElseIf lbl1.Text = "It is 0's Move =)" Then
btn5.Image = My.Resources._0
btn5.Tag = "1"
lbl1.Text = "It is X's Move =)"
btn1.BackColor = Color.Transparent
btn2.BackColor = Color.Transparent
btn3.BackColor = Color.Transparent
btn4.BackColor = Color.Transparent
btn5.BackColor = Color.Transparent
btn6.BackColor = Color.Transparent
btn7.BackColor = Color.Transparent
btn8.BackColor = Color.Transparent
btn9.BackColor = Color.Transparent
Else
If btn1.Tag = Nothing Then
btn1.BackColor = Color.Red
End If
If btn2.Tag = Nothing Then
btn2.BackColor = Color.Red
End If
If btn3.Tag = Nothing Then
btn3.BackColor = Color.Red
End If
If btn4.Tag = Nothing Then
btn4.BackColor = Color.Red
End If
If btn6.Tag = Nothing Then
btn6.BackColor = Color.Red
End If
If btn7.Tag = Nothing Then
btn7.BackColor = Color.Red
End If
If btn8.Tag = Nothing Then
btn8.BackColor = Color.Red
End If
If btn9.Tag = Nothing Then
btn9.BackColor = Color.Red
End If
End If
End Sub
Private Sub btn6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn6.Click
btn6.Image = Nothing
btn6.Tag = Nothing
If btn6.BackColor = Color.Red Then
If lbl1.Text = "It is X's Move =)" Then
btn6.Image = My.Resources.X
btn6.Tag = "1"
lbl1.Text = "It is 0's Move =)"
btn1.BackColor = Color.Transparent
btn2.BackColor = Color.Transparent
btn3.BackColor = Color.Transparent
btn4.BackColor = Color.Transparent
btn5.BackColor = Color.Transparent
btn6.BackColor = Color.Transparent
btn7.BackColor = Color.Transparent
btn8.BackColor = Color.Transparent
btn9.BackColor = Color.Transparent
Else
If btn2.Tag = Nothing Then
btn2.BackColor = Color.Red
End If
If btn3.Tag = Nothing Then
btn3.BackColor = Color.Red
End If
If btn5.Tag = Nothing Then
btn5.BackColor = Color.Red
End If
If btn8.Tag = Nothing Then
btn8.BackColor = Color.Red
End If
If btn9.Tag = Nothing Then
btn9.BackColor = Color.Red
End If
End If
ElseIf lbl1.Text = "It is 0's Move =)" Then
btn6.Image = My.Resources._0
btn6.Tag = "1"
lbl1.Text = "It is X's Move =)"
btn1.BackColor = Color.Transparent
btn2.BackColor = Color.Transparent
btn3.BackColor = Color.Transparent
btn4.BackColor = Color.Transparent
btn5.BackColor = Color.Transparent
btn6.BackColor = Color.Transparent
btn7.BackColor = Color.Transparent
btn8.BackColor = Color.Transparent
btn9.BackColor = Color.Transparent
Else
If btn2.Tag = Nothing Then
btn2.BackColor = Color.Red
End If
If btn3.Tag = Nothing Then
btn3.BackColor = Color.Red
End If
If btn5.Tag = Nothing Then
btn5.BackColor = Color.Red
End If
If btn8.Tag = Nothing Then
btn8.BackColor = Color.Red
End If
If btn9.Tag = Nothing Then
btn9.BackColor = Color.Red
End If
End If
End Sub
Private Sub btn7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn7.Click
btn7.Image = Nothing
btn7.Tag = Nothing
If btn7.BackColor = Color.Red Then
If lbl1.Text = "It is X's Move =)" Then
btn7.Image = My.Resources.X
btn7.Tag = "1"
lbl1.Text = "It is 0's Move =)"
btn1.BackColor = Color.Transparent
btn2.BackColor = Color.Transparent
btn3.BackColor = Color.Transparent
btn4.BackColor = Color.Transparent
btn5.BackColor = Color.Transparent
btn6.BackColor = Color.Transparent
btn7.BackColor = Color.Transparent
btn8.BackColor = Color.Transparent
btn9.BackColor = Color.Transparent
Else
If btn4.Tag = Nothing Then
btn4.BackColor = Color.Red
End If
If btn5.Tag = Nothing Then
btn5.BackColor = Color.Red
End If
If btn8.Tag = Nothing Then
btn8.BackColor = Color.Red
End If
End If
ElseIf lbl1.Text = "It is 0's Move =)" Then
btn7.Image = My.Resources._0
btn7.Tag = "1"
lbl1.Text = "It is X's Move =)"
btn1.BackColor = Color.Transparent
btn2.BackColor = Color.Transparent
btn3.BackColor = Color.Transparent
btn4.BackColor = Color.Transparent
btn5.BackColor = Color.Transparent
btn6.BackColor = Color.Transparent
btn7.BackColor = Color.Transparent
btn8.BackColor = Color.Transparent
btn9.BackColor = Color.Transparent
Else
If btn4.Tag = Nothing Then
btn4.BackColor = Color.Red
End If
If btn5.Tag = Nothing Then
btn5.BackColor = Color.Red
End If
If btn8.Tag = Nothing Then
btn8.BackColor = Color.Red
End If
End If
End Sub
Private Sub btn8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn8.Click
btn8.Image = Nothing
btn8.Tag = Nothing
If btn8.BackColor = Color.Red Then
If lbl1.Text = "It is X's Move =)" Then
btn8.Image = My.Resources.X
btn8.Tag = "1"
lbl1.Text = "It is 0's Move =)"
btn1.BackColor = Color.Transparent
btn2.BackColor = Color.Transparent
btn3.BackColor = Color.Transparent
btn4.BackColor = Color.Transparent
btn5.BackColor = Color.Transparent
btn6.BackColor = Color.Transparent
btn7.BackColor = Color.Transparent
btn8.BackColor = Color.Transparent
btn9.BackColor = Color.Transparent
Else
If btn4.Tag = Nothing Then
btn4.BackColor = Color.Red
End If
If btn5.Tag = Nothing Then
btn5.BackColor = Color.Red
End If
If btn6.Tag = Nothing Then
btn6.BackColor = Color.Red
End If
If btn7.Tag = Nothing Then
btn7.BackColor = Color.Red
End If
If btn9.Tag = Nothing Then
btn9.BackColor = Color.Red
End If
End If
ElseIf lbl1.Text = "It is 0's Move =)" Then
btn8.Image = My.Resources._0
btn8.Tag = "1"
lbl1.Text = "It is X's Move =)"
btn1.BackColor = Color.Transparent
btn2.BackColor = Color.Transparent
btn3.BackColor = Color.Transparent
btn4.BackColor = Color.Transparent
btn5.BackColor = Color.Transparent
btn6.BackColor = Color.Transparent
btn7.BackColor = Color.Transparent
btn8.BackColor = Color.Transparent
btn9.BackColor = Color.Transparent
Else
If btn4.Tag = Nothing Then
btn4.BackColor = Color.Red
End If
If btn5.Tag = Nothing Then
btn5.BackColor = Color.Red
End If
If btn6.Tag = Nothing Then
btn6.BackColor = Color.Red
End If
If btn7.Tag = Nothing Then
btn7.BackColor = Color.Red
End If
If btn9.Tag = Nothing Then
btn9.BackColor = Color.Red
End If
End If
End Sub
Private Sub btn9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn9.Click
btn9.Image = Nothing
btn9.Tag = Nothing
If btn9.BackColor = Color.Red Then
If lbl1.Text = "It is X's Move =)" Then
btn9.Image = My.Resources.X
btn9.Tag = "1"
lbl1.Text = "It is 0's Move =)"
btn1.BackColor = Color.Transparent
btn2.BackColor = Color.Transparent
btn3.BackColor = Color.Transparent
btn4.BackColor = Color.Transparent
btn5.BackColor = Color.Transparent
btn6.BackColor = Color.Transparent
btn7.BackColor = Color.Transparent
btn8.BackColor = Color.Transparent
btn9.BackColor = Color.Transparent
Else
If btn5.Tag = Nothing Then
btn5.BackColor = Color.Red
End If
If btn6.Tag = Nothing Then
btn6.BackColor = Color.Red
End If
If btn8.Tag = Nothing Then
btn8.BackColor = Color.Red
End If
End If
ElseIf lbl1.Text = "It is 0's Move =)" Then
btn9.Image = My.Resources._0
btn9.Tag = "1"
lbl1.Text = "It is X's Move =)"
btn1.BackColor = Color.Transparent
btn2.BackColor = Color.Transparent
btn3.BackColor = Color.Transparent
btn4.BackColor = Color.Transparent
btn5.BackColor = Color.Transparent
btn6.BackColor = Color.Transparent
btn7.BackColor = Color.Transparent
btn8.BackColor = Color.Transparent
btn9.BackColor = Color.Transparent
Else
If btn5.Tag = Nothing Then
btn5.BackColor = Color.Red
End If
If btn6.Tag = Nothing Then
btn6.BackColor = Color.Red
End If
If btn8.Tag = Nothing Then
btn8.BackColor = Color.Red
End If
End If
End Sub
End Class


This file is hosted off-site.
Download link not working :?
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
ohh sorry try this link
https://dl.dropboxusercontent.com/u/44654220/Game.zip
Not sure why it messed up then
https://dl.dropboxusercontent.com/u/44654220/Game.zip
Not sure why it messed up then
This looks like a game of TicTacToe... but it doesn't work like a game of TicTacToe :?
Could you explain what it's supposed to do? Because to me it seems to be working fine lol.
Could you explain what it's supposed to do? Because to me it seems to be working fine lol.
its odd to explain but ill do my best
The aim is to get your 3 pieces to a new three in a row
but you can only move one space at a time and if someone
is blocking the way you want to move then you cant move that way
so if your left was free you may move one space left but if 0 was their you could not move, The aim is to move all your pieces to a new three in a row without getting stuck of making the game a draw.
The problem is it moves fine for player X but 0s wont move at all for me
ohh and sometimes it adds more then 3 of each player. and it wont currently message if three are in a row that isnt their starting row

The aim is to get your 3 pieces to a new three in a row
but you can only move one space at a time and if someone
is blocking the way you want to move then you cant move that way
so if your left was free you may move one space left but if 0 was their you could not move, The aim is to move all your pieces to a new three in a row without getting stuck of making the game a draw.
The problem is it moves fine for player X but 0s wont move at all for me
ohh and sometimes it adds more then 3 of each player. and it wont currently message if three are in a row that isnt their starting row
5 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023