Tic Tac Toe issue

Need some advice please

Page 1 of 1

1 Replies - 1543 Views - Last Post: 03 May 2009 - 01:48 AM Rate Topic: -----

#1 wingspegasus  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 05-April 09

Tic Tac Toe issue

Posted 02 May 2009 - 08:10 PM

Attached File  2_TicTacToe_Solution.zip (115.68K)
Number of downloads: 90

Quote

Hello
yes there are several pages of tic tac toe, and they seem to be on different levels than I am.
I do not want to copy code I would like to understand/picture the problem...maybe someone could offer pseudo-code to help me see a solution.

I have an interface that has 9 textboxes 1-9 within a container. I have a quit or play again button and a start button
I have declared variables that I have not used. This is my full code. I know I have yet to begin anything serious which is why I asked for some pseudo code or just advice on how to approach this. I am way beginner and I cannot use code we have not learned...I could but I do not think that is appropriate.

If anyone has time can you tell me how I might approach this? I started out with buttons but changed that because I could not see what to do with it. I also am not sure about arrays and how to use them for this. In the text they show arrays for months or states in listboxes, but nothing like this with only 2 letters.

thanks and please let me know what you think.
Option Explicit On
Option Strict On
Option Infer Off

Public Class mainForm

   'clears text from buttons and textbox
	Private Sub ClearButtons()
		TextBox1.Text = String.Empty
		TextBox2.Text = String.Empty
		TextBox3.Text = String.Empty
		TextBox4.Text = String.Empty
		TextBox5.Text = String.Empty
		TextBox6.Text = String.Empty
		TextBox7.Text = String.Empty
		TextBox8.Text = String.Empty
		TextBox9.Text = String.Empty


	End Sub

	Private Sub playQuitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles playQuitButton.Click

		If MessageBox.Show("play another game?", "Tic Tac Toe Game", MessageBoxButtons.YesNo, _
		MessageBoxIcon.Exclamation) = Windows.Forms.DialogResult.Yes Then
			Call ClearButtons()

		Else
			Me.Close()
		End If
	End Sub

	Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)

		'accepts only X, x or O, o and backspace in text box 

		If e.KeyChar <> "O" AndAlso e.KeyChar <> "o" AndAlso e.KeyChar <> "X" AndAlso e.KeyChar <> "x" _
		AndAlso e.KeyChar <> ControlChars.Back Then
			e.Handled = True
		End If

	End Sub

	Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)

		'accepts only X, x or O, o and backspace in text box 
		If e.KeyChar <> "O" AndAlso e.KeyChar <> "o" AndAlso e.KeyChar <> "X" AndAlso e.KeyChar <> "x" _
		AndAlso e.KeyChar <> ControlChars.Back Then
			e.Handled = True
		End If
	End Sub
	Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)

		'accepts only X, x or O, o and backspace in text box 
		If e.KeyChar <> "O" AndAlso e.KeyChar <> "o" AndAlso e.KeyChar <> "X" AndAlso e.KeyChar <> "x" _
		AndAlso e.KeyChar <> ControlChars.Back Then
			e.Handled = True
		End If
	End Sub
	Private Sub TextBox4_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)

		'accepts only X, x or O, o and backspace in text box 
		If e.KeyChar <> "O" AndAlso e.KeyChar <> "o" AndAlso e.KeyChar <> "X" AndAlso e.KeyChar <> "x" _
		AndAlso e.KeyChar <> ControlChars.Back Then
			e.Handled = True
		End If
	End Sub
	Private Sub TextBox5_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)

		'accepts only X, x or O, o and backspace in text box 
		If e.KeyChar <> "O" AndAlso e.KeyChar <> "o" AndAlso e.KeyChar <> "X" AndAlso e.KeyChar <> "x" _
		AndAlso e.KeyChar <> ControlChars.Back Then
			e.Handled = True
		End If
	End Sub
	Private Sub TextBox6_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)

		'accepts only X, x or O, o and backspace in text box 
		If e.KeyChar <> "O" AndAlso e.KeyChar <> "o" AndAlso e.KeyChar <> "X" AndAlso e.KeyChar <> "x" _
		AndAlso e.KeyChar <> ControlChars.Back Then
			e.Handled = True
		End If
	End Sub
	Private Sub TextBox7_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)

		'accepts only X, x or O, o and backspace in text box 
		If e.KeyChar <> "O" AndAlso e.KeyChar <> "o" AndAlso e.KeyChar <> "X" AndAlso e.KeyChar <> "x" _
		AndAlso e.KeyChar <> ControlChars.Back Then
			e.Handled = True
		End If
	End Sub
	Private Sub TextBox8_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)

		'accepts only X, x or O, o and backspace in text box 
		If e.KeyChar <> "O" AndAlso e.KeyChar <> "o" AndAlso e.KeyChar <> "X" AndAlso e.KeyChar <> "x" _
		AndAlso e.KeyChar <> ControlChars.Back Then
			e.Handled = True
		End If
	End Sub
	Private Sub TextBox9_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)

		'accepts only X, x or O, o and backspace in text box 
		If e.KeyChar <> "O" AndAlso e.KeyChar <> "o" AndAlso e.KeyChar <> "X" AndAlso e.KeyChar <> "x" _
		AndAlso e.KeyChar <> ControlChars.Back Then
			e.Handled = True
		End If
	End Sub

	Private Sub startButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles startButton.Click

		'ask player 1 to begin
		MessageBox.Show("First player, please type an X in a square", "Tic-Tac-Toe", MessageBoxButtons.OK)


		'declare variables assign values
		Dim plyr1 As Char
		Dim plyr2 As Char
		Dim x As Char
		Dim o As Char
		Dim i As Integer
		Dim panel(2, 2) As Integer

	   
		plyr1 = x
		plyr2 = o

		


	End Sub
End Class



Is This A Good Question/Topic? 0
  • +

Replies To: Tic Tac Toe issue

#2 firebolt  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 92
  • View blog
  • Posts: 5,561
  • Joined: 20-February 09

Re: Tic Tac Toe issue

Posted 03 May 2009 - 01:48 AM

I have a vb.net tutorial if you want the link.

VB.NET link.
http://visualbasic.a...l/aa093002a.htm

It may help as it shows documentation

This post has been edited by firebolt: 03 May 2009 - 01:46 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1