Stealing lillies
New member
- Joined
- Nov 5, 2005
- Messages
- 1
- Programming Experience
- Beginner
Im a new to your forums so i may have missed some rules and what not.I do appoligize if i have posted in the wrong forum or break any rules about content.
The thing is i have been working for days on this program and am stumped. I cant seem to get it to win or stop with a winner. It seems to me i may have put way to much into a simple program such as Tic-Tac-Toe, but anyways i was hopeing maybe someone here could help me out on this.
This is what i have so far and am stuck at this point.
Any help would really be appriciated!
The thing is i have been working for days on this program and am stumped. I cant seem to get it to win or stop with a winner. It seems to me i may have put way to much into a simple program such as Tic-Tac-Toe, but anyways i was hopeing maybe someone here could help me out on this.
This is what i have so far and am stuck at this point.
VB.NET:
Dim count_turn As Integer
Private Sub lbl1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbl1.Click
Dim check_turn As Integer
WhoTurn(check_turn)
If check_turn = 1 Then lbl1.Text = "X"
If check_turn = 0 Then lbl1.Text = "0"
lbl1.Enabled = False
End Sub
Private Sub lbl2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbl2.Click
Dim check_turn As Integer
WhoTurn(check_turn)
If check_turn = 1 Then lbl2.Text = "X"
If check_turn = 0 Then lbl2.Text = "0"
lbl2.Enabled = False
End Sub
Private Sub lbl3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbl3.Click
Dim check_turn As Integer
WhoTurn(check_turn)
If check_turn = 1 Then lbl3.Text = "X"
If check_turn = 0 Then lbl3.Text = "0"
lbl3.Enabled = False
End Sub
Private Sub lbl4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbl4.Click
Dim check_turn As Integer
WhoTurn(check_turn)
If check_turn = 1 Then lbl4.Text = "X"
If check_turn = 0 Then lbl4.Text = "0"
lbl4.Enabled = False
End Sub
Private Sub lbl5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbl5.Click
Dim check_turn As Integer
WhoTurn(check_turn)
If check_turn = 1 Then lbl5.Text = "X"
If check_turn = 0 Then lbl5.Text = "0"
lbl5.Enabled = False
End Sub
Private Sub lbl6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbl6.Click
Dim check_turn As Integer
WhoTurn(check_turn)
If check_turn = 1 Then lbl6.Text = "X"
If check_turn = 0 Then lbl6.Text = "0"
lbl6.Enabled = False
End Sub
Private Sub lbl7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbl7.Click
Dim check_turn As Integer
WhoTurn(check_turn)
If check_turn = 1 Then lbl7.Text = "X"
If check_turn = 0 Then lbl7.Text = "0"
lbl7.Enabled = False
End Sub
Private Sub lbl8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbl8.Click
Dim check_turn As Integer
WhoTurn(check_turn)
If check_turn = 1 Then lbl8.Text = "X"
If check_turn = 0 Then lbl8.Text = "0"
lbl8.Enabled = False
End Sub
Private Sub lbl9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbl9.Click
Dim check_turn As Integer
WhoTurn(check_turn)
If check_turn = 1 Then lbl9.Text = "X"
If check_turn = 0 Then lbl9.Text = "0"
lbl9.Enabled = False
End Sub
Sub WhoTurn(ByRef check_turn As Integer)
count_turn = count_turn + 1
If count_turn = 1 Then check_turn = 1
If count_turn = 2 Then check_turn = 0
If count_turn = 3 Then check_turn = 1
If count_turn = 4 Then check_turn = 0
If count_turn = 5 Then check_turn = 1
If count_turn = 6 Then check_turn = 0
If count_turn = 7 Then check_turn = 1
If count_turn = 8 Then check_turn = 0
If count_turn = 9 Then check_turn = 1
End Sub
Private Sub checkForWinner(ByVal PlayerNumber As Integer)
Dim chr As String = ""
Select Case PlayerNumber
Case 1
chr = "X"
Case 2
chr = "O"
End Select
If (lbl1.Text = chr And lbl2.Text = chr And lbl3.Text = chr) _
Or (lbl4.Text = chr And lbl5.Text = chr And lbl6.Text = chr) _
Or (lbl7.Text = chr And lbl8.Text = chr And lbl9.Text = chr) _
Or (lbl1.Text = chr And lbl4.Text = chr And lbl7.Text = chr) _
Or (lbl2.Text = chr And lbl5.Text = chr And lbl8.Text = chr) _
Or (lbl3.Text = chr And lbl6.Text = chr And lbl9.Text = chr) _
Or (lbl1.Text = chr And lbl5.Text = chr And lbl9.Text = chr) _
Or (lbl3.Text = chr And lbl5.Text = chr And lbl7.Text = chr) Then
End If
End Sub
Last edited by a moderator: