Tic-Tac-Toe Game Help

Hello all, I am new here, and I'm just looking for a bit of help on my program. Although I am in Computer Science class, this is not a project and I'm just doing it for my own interest. It is a Tic-Tac-Toe game, and I have written what I believe to be all of it, but for some reason it does not work. I think it has something to do with the fact that I only used one variable, or maybe something else about the variable, but I'm not sure. If anyone has the time to look it over and help me out, here is the code: (I used visual C++ the free one, you can just paste it into a new one and then rebuild the solution).

Also, thanks to anyone who read this.


#pragma once


namespace TicTacToe {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;

	/// <summary>
	/// Summary for Form1
	///
	/// WARNING: If you change the name of this class, you will need to change the
	///          'Resource File Name' property for the managed resource compiler tool
	///          associated with all .resx files this class depends on.  Otherwise,
	///          the designers will not be able to interact properly with localized
	///          resources associated with this form.
	/// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}

	protected: 









	private: System::Windows::Forms::Button^  button10;
	private: System::Windows::Forms::Button^  button11;
	private: System::Windows::Forms::Button^  button12;
	private: System::Windows::Forms::Panel^  panel1;
	private: System::Windows::Forms::Button^  button9;
	private: System::Windows::Forms::Button^  button8;
	private: System::Windows::Forms::Button^  button7;
	private: System::Windows::Forms::Button^  button6;
	private: System::Windows::Forms::Button^  button5;
	private: System::Windows::Forms::Button^  button4;
	private: System::Windows::Forms::Button^  button3;
	private: System::Windows::Forms::Button^  button2;
	private: System::Windows::Forms::Button^  button1;



	private:
		/// <summary>
		int Turn;
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			this->button10 = (gcnew System::Windows::Forms::Button());
			this->button11 = (gcnew System::Windows::Forms::Button());
			this->button12 = (gcnew System::Windows::Forms::Button());
			this->panel1 = (gcnew System::Windows::Forms::Panel());
			this->button9 = (gcnew System::Windows::Forms::Button());
			this->button8 = (gcnew System::Windows::Forms::Button());
			this->button7 = (gcnew System::Windows::Forms::Button());
			this->button6 = (gcnew System::Windows::Forms::Button());
			this->button5 = (gcnew System::Windows::Forms::Button());
			this->button4 = (gcnew System::Windows::Forms::Button());
			this->button3 = (gcnew System::Windows::Forms::Button());
			this->button2 = (gcnew System::Windows::Forms::Button());
			this->button1 = (gcnew System::Windows::Forms::Button());
			this->panel1->SuspendLayout();
			this->SuspendLayout();
			// 
			// button10
			// 
			this->button10->BackColor = System::Drawing::Color::Black;
			this->button10->FlatAppearance->BorderSize = 0;
			this->button10->FlatStyle = System::Windows::Forms::FlatStyle::Flat;
			this->button10->Font = (gcnew System::Drawing::Font(L"Calibri", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->button10->ForeColor = System::Drawing::Color::White;
			this->button10->Location = System::Drawing::Point(87, 268);
			this->button10->Name = L"button10";
			this->button10->Size = System::Drawing::Size(80, 33);
			this->button10->TabIndex = 10;
			this->button10->Text = L"Start";
			this->button10->UseVisualStyleBackColor = false;
			this->button10->Click += gcnew System::EventHandler(this, &Form1::button10_Click);
			// 
			// button11
			// 
			this->button11->BackColor = System::Drawing::Color::Black;
			this->button11->FlatAppearance->BorderSize = 0;
			this->button11->FlatStyle = System::Windows::Forms::FlatStyle::Flat;
			this->button11->Font = (gcnew System::Drawing::Font(L"Calibri", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->button11->ForeColor = System::Drawing::Color::White;
			this->button11->Location = System::Drawing::Point(315, 268);
			this->button11->Name = L"button11";
			this->button11->Size = System::Drawing::Size(88, 33);
			this->button11->TabIndex = 11;
			this->button11->Text = L"Quit";
			this->button11->UseVisualStyleBackColor = false;
			this->button11->Click += gcnew System::EventHandler(this, &Form1::button11_Click);
			// 
			// button12
			// 
			this->button12->BackColor = System::Drawing::Color::Black;
			this->button12->FlatAppearance->BorderSize = 0;
			this->button12->FlatStyle = System::Windows::Forms::FlatStyle::Flat;
			this->button12->Font = (gcnew System::Drawing::Font(L"Calibri", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->button12->ForeColor = System::Drawing::Color::White;
			this->button12->Location = System::Drawing::Point(12, 268);
			this->button12->Name = L"button12";
			this->button12->Size = System::Drawing::Size(69, 33);
			this->button12->TabIndex = 12;
			this->button12->Text = L"Reset";
			this->button12->UseVisualStyleBackColor = false;
			this->button12->Click += gcnew System::EventHandler(this, &Form1::button12_Click);
			// 
			// panel1
			// 
			this->panel1->BackColor = System::Drawing::Color::White;
			this->panel1->Controls->Add(this->button9);
			this->panel1->Controls->Add(this->button8);
			this->panel1->Controls->Add(this->button7);
			this->panel1->Controls->Add(this->button6);
			this->panel1->Controls->Add(this->button5);
			this->panel1->Controls->Add(this->button4);
			this->panel1->Controls->Add(this->button3);
			this->panel1->Controls->Add(this->button2);
			this->panel1->Controls->Add(this->button1);
			this->panel1->Font = (gcnew System::Drawing::Font(L"Calibri", 18, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->panel1->Location = System::Drawing::Point(97, 35);
			this->panel1->Name = L"panel1";
			this->panel1->Size = System::Drawing::Size(215, 202);
			this->panel1->TabIndex = 13;
			// 
			// button9
			// 
			this->button9->BackColor = System::Drawing::Color::Black;
			this->button9->FlatStyle = System::Windows::Forms::FlatStyle::Flat;
			this->button9->Font = (gcnew System::Drawing::Font(L"Tahoma", 26.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->button9->ForeColor = System::Drawing::Color::White;
			this->button9->Location = System::Drawing::Point(149, 140);
			this->button9->Name = L"button9";
			this->button9->Size = System::Drawing::Size(69, 65);
			this->button9->TabIndex = 17;
			this->button9->Text = L" ";
			this->button9->UseVisualStyleBackColor = false;
			this->button9->Click += gcnew System::EventHandler(this, 

[/output]

&Form1::button9_Click);
			// 
			// button8
			// 
			this->button8->BackColor = System::Drawing::Color::Black;
			this->button8->FlatStyle = System::Windows::Forms::FlatStyle::Flat;
			this->button8->Font = (gcnew System::Drawing::Font(L"Tahoma", 26.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->button8->ForeColor = System::Drawing::Color::White;
			this->button8->Location = System::Drawing::Point(74, 140);
			this->button8->Name = L"button8";
			this->button8->Size = System::Drawing::Size(69, 65);
			this->button8->TabIndex = 16;
			this->button8->Text = L" ";
			this->button8->UseVisualStyleBackColor = false;
			this->button8->Click += gcnew System::EventHandler(this, &Form1::button8_Click);
			// 
			// button7
			// 
			this->button7->BackColor = System::Drawing::Color::Black;
			this->button7->FlatStyle = System::Windows::Forms::FlatStyle::Flat;
			this->button7->Font = (gcnew System::Drawing::Font(L"Tahoma", 26.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->button7->ForeColor = System::Drawing::Color::White;
			this->button7->Location = System::Drawing::Point(-2, 140);
			this->button7->Name = L"button7";
			this->button7->Size = System::Drawing::Size(71, 65);
			this->button7->TabIndex = 15;
			this->button7->Text = L" ";
			this->button7->UseVisualStyleBackColor = false;
			this->button7->Click += gcnew System::EventHandler(this, &Form1::button7_Click);
			// 
			// button6
			// 
			this->button6->BackColor = System::Drawing::Color::Black;
			this->button6->FlatStyle = System::Windows::Forms::FlatStyle::Flat;
			this->button6->Font = (gcnew System::Drawing::Font(L"Tahoma", 26.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->button6->ForeColor = System::Drawing::Color::White;
			this->button6->Location = System::Drawing::Point(149, 69);
			this->button6->Name = L"button6";
			this->button6->Size = System::Drawing::Size(69, 65);
			this->button6->TabIndex = 14;
			this->button6->Text = L" ";
			this->button6->UseVisualStyleBackColor = false;
			this->button6->Click += gcnew System::EventHandler(this, &Form1::button6_Click);
			// 
			// button5
			// 
			this->button5->BackColor = System::Drawing::Color::Black;
			this->button5->FlatStyle = System::Windows::Forms::FlatStyle::Flat;
			this->button5->Font = (gcnew System::Drawing::Font(L"Tahoma", 26.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->button5->ForeColor = System::Drawing::Color::White;
			this->button5->Location = System::Drawing::Point(74, 69);
			this->button5->Name = L"button5";
			this->button5->Size = System::Drawing::Size(69, 65);
			this->button5->TabIndex = 13;
			this->button5->Text = L" ";
			this->button5->UseVisualStyleBackColor = false;
			this->button5->Click += gcnew System::EventHandler(this, &Form1::button5_Click);
			// 
			// button4
			// 
			this->button4->BackColor = System::Drawing::Color::Black;
			this->button4->FlatStyle = System::Windows::Forms::FlatStyle::Flat;
			this->button4->Font = (gcnew System::Drawing::Font(L"Tahoma", 26.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->button4->ForeColor = System::Drawing::Color::White;
			this->button4->Location = System::Drawing::Point(-2, 69);
			this->button4->Name = L"button4";
			this->button4->Size = System::Drawing::Size(71, 65);
			this->button4->TabIndex = 12;
			this->button4->Text = L" ";
			this->button4->UseVisualStyleBackColor = false;
			this->button4->Click += gcnew System::EventHandler(this, &Form1::button4_Click);
			// 
			// button3
			// 
			this->button3->BackColor = System::Drawing::Color::Black;
			this->button3->FlatStyle = System::Windows::Forms::FlatStyle::Flat;
			this->button3->Font = (gcnew System::Drawing::Font(L"Tahoma", 26.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->button3->ForeColor = System::Drawing::Color::White;
			this->button3->Location = System::Drawing::Point(149, -2);
			this->button3->Name = L"button3";
			this->button3->Size = System::Drawing::Size(69, 65);
			this->button3->TabIndex = 11;
			this->button3->Text = L" ";
			this->button3->UseVisualStyleBackColor = false;
			this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);
			// 
			// button2
			// 
			this->button2->BackColor = System::Drawing::Color::Black;
			this->button2->FlatStyle = System::Windows::Forms::FlatStyle::Flat;
			this->button2->Font = (gcnew System::Drawing::Font(L"Tahoma", 26.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->button2->ForeColor = System::Drawing::Color::White;
			this->button2->Location = System::Drawing::Point(74, -2);
			this->button2->Name = L"button2";
			this->button2->Size = System::Drawing::Size(69, 65);
			this->button2->TabIndex = 10;
			this->button2->Text = L" ";
			this->button2->UseVisualStyleBackColor = false;
			this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
			// 
			// button1
			// 
			this->button1->BackColor = System::Drawing::Color::Black;
			this->button1->FlatStyle = System::Windows::Forms::FlatStyle::Flat;
			this->button1->Font = (gcnew System::Drawing::Font(L"Tahoma", 26.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->button1->ForeColor = System::Drawing::Color::White;
			this->button1->Location = System::Drawing::Point(-2, -2);
			this->button1->Name = L"button1";
			this->button1->Size = System::Drawing::Size(71, 65);
			this->button1->TabIndex = 9;
			this->button1->Text = L" ";
			this->button1->UseVisualStyleBackColor = false;
			this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->BackColor = System::Drawing::Color::Black;
			this->ClientSize = System::Drawing::Size(415, 313);
			this->Controls->Add(this->button12);
			this->Controls->Add(this->button11);
			this->Controls->Add(this->button10);
			this->Controls->Add(this->panel1);
			this->ForeColor = System::Drawing::Color::White;
			this->Name = L"Form1";
			this->Text = L"Tic-Tac-Toe";
			this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
			this->panel1->ResumeLayout(false);
			this->ResumeLayout(false);

		}

Last edited on

#pragma endregion
	private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
			 button10->Enabled = true;
			 button1->Enabled = false;
			 button2->Enabled = false;
			 button3->Enabled = false;
			 button4->Enabled = false;
			 button5->Enabled = false;
			 button6->Enabled = false;
			 button7->Enabled = false;
			 button8->Enabled = false;
			 button9->Enabled = false;
			 button12->Enabled = false;
			 if (button1->Text == "X" && button2->Text == "X" && button3->Text == "X")
			 {MessageBox::Show("Player 1 Wins!");}
			 if (button4->Text == "X" && button5->Text == "X" && button6->Text == "X")
			 {MessageBox::Show("Player 1 Wins!");}
			 if (button7->Text == "X" && button8->Text == "X" && button9->Text == "X")
			 {MessageBox::Show("Player 1 Wins!");}
			 if (button1->Text == "X" && button4->Text == "X" && button7->Text == "X")
			 {MessageBox::Show("Player 1 Wins!");}
			 if (button2->Text == "X" && button5->Text == "X" && button8->Text == "X")
			 {MessageBox::Show("Player 1 Wins!");}
			 if (button3->Text == "X" && button6->Text == "X" && button9->Text == "X")
			 {MessageBox::Show("Player 1 Wins!");}
			 if (button1->Text == "X" && button5->Text == "X" && button9->Text == "X")
			 {MessageBox::Show("Player 1 Wins!");}
			 if (button3->Text == "X" && button5->Text == "X" && button7->Text == "X")
			 {MessageBox::Show("Player 1 Wins!");}
			 if (button1->Text == "O" && button2->Text == "O" && button3->Text == "O")
			 {MessageBox::Show("Player 2 Wins!");}
			 if (button4->Text == "O" && button5->Text == "O" && button6->Text == "O")
			 {MessageBox::Show("Player 2 Wins!");}
			 if (button7->Text == "O" && button8->Text == "O" && button9->Text == "O")
			 {MessageBox::Show("Player 2 Wins!");}
			 if (button1->Text == "O" && button4->Text == "O" && button7->Text == "O")
			 {MessageBox::Show("Player 2 Wins!");}
			 if (button2->Text == "O" && button5->Text == "O" && button8->Text == "O")
			 {MessageBox::Show("Player 2 Wins!");}
			 if (button3->Text == "O" && button6->Text == "O" && button9->Text == "O")
			 {MessageBox::Show("Player 2 Wins!");}
			 if (button1->Text == "O" && button5->Text == "O" && button9->Text == "O")
			 {MessageBox::Show("Player 2 Wins!");}
			 if (button3->Text == "O" && button5->Text == "O" && button7->Text == "O")
			 {MessageBox::Show("Player 2 Wins!");}
			 }
private: System::Void button11_Click(System::Object^  sender, System::EventArgs^  e) {
			 Close();
		 }
private: System::Void button12_Click(System::Object^  sender, System::EventArgs^  e) {
			 Turn = 1;
			 button10->Enabled = true;
			 button12->Enabled = false;
			 button1->Text = " ";
			 button2->Text = " ";
			 button3->Text = " ";
			 button4->Text = " ";
			 button5->Text = " ";
			 button6->Text = " ";
			 button7->Text = " ";
			 button8->Text = " ";
			 button9->Text = " ";
		 }
private: System::Void button10_Click(System::Object^  sender, System::EventArgs^  e) {
			 button1->Enabled = true;
			 button2->Enabled = true;
			 button3->Enabled = true;
			 button4->Enabled = true;
			 button5->Enabled = true;
			 button6->Enabled = true;
			 button7->Enabled = true;
			 button8->Enabled = true;
			 button9->Enabled = true;
			 MessageBox::Show("This Is Two-Player Tic-Tac-Toe! X Is Player 1. Try Your Best To Get Three In A Row!");
			 Turn = 1;
			 button10->Enabled = false;
			 button12->Enabled = true;
		 }
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
			 if (Turn == 1)
			 {button1->Text = "X";
			 Turn++;
			 button1->Enabled = false;}
			 if (Turn == 2)
			 {button1->Text = "O";
			 Turn++;
			 button1->Enabled = false;}
			 if (Turn == 3)
			 {button1->Text = "X";
			 Turn++;
			 button1->Enabled = false;}
			 if (Turn == 4)
			 {button1->Text = "O";
			 Turn++;
			 button1->Enabled = false;}
			 if (Turn == 5)
			 {button1->Text = "X";
			 Turn++;
			 button1->Enabled = false;}
			 if (Turn == 6)
			 {button1->Text = "O";
			 Turn++;
			 button1->Enabled = false;}
			 if (Turn == 7)
			 {button1->Text = "X";
			 Turn++;
			 button1->Enabled = false;}
			 if (Turn == 8)
			 {button1->Text = "O";
			 Turn++;
			 button1->Enabled = false;}
			 if (Turn == 9)
			 {button1->Text = "X";
			 Turn++;
			 button1->Enabled = false;}
		 }
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
			 if (Turn == 1)
			 {button2->Text = "X";
			 Turn++;
			 button2->Enabled = false;}
			 if (Turn == 2)
			 {button2->Text = "O";
			 Turn++;
			 button2->Enabled = false;}
			 if (Turn == 3)
			 {button2->Text = "X";
			 Turn++;
			 button2->Enabled = false;}
			 if (Turn == 4)
			 {button2->Text = "O";
			 Turn++;
			 button2->Enabled = false;}
			 if (Turn == 5)
			 {button2->Text = "X";
			 Turn++;
			 button2->Enabled = false;}
			 if (Turn == 6)
			 {button2->Text = "O";
			 Turn++;
			 button2->Enabled = false;}
			 if (Turn == 7)
			 {button2->Text = "X";
			 Turn++;
			 button2->Enabled = false;}
			 if (Turn == 8)
			 {button2->Text = "O";
			 Turn++;
			 button2->Enabled = false;}
			 if (Turn == 9)
			 {button2->Text = "X";
			 Turn++;
			 button2->Enabled = false;}
		 }
private: System::Void button3_Click(System::Object^  sender, System::EventArgs^  e) {
			 if (Turn == 1)
			 {button3->Text = "X";
			 Turn++;
			 button3->Enabled = false;}
			 if (Turn == 2)
			 {button3->Text = "O";
			 Turn++;
			 button3->Enabled = false;}
			 if (Turn == 3)
			 {button3->Text = "X";
			 Turn++;
			 button3->Enabled = false;}
			 if (Turn == 4)
			 {button3->Text = "O";
			 Turn++;
			 button3->Enabled = false;}
			 if (Turn == 5)
			 {button3->Text = "X";
			 Turn++;
			 button3->Enabled = false;}
			 if (Turn == 6)
			 {button3->Text = "O";
			 Turn++;
			 button3->Enabled = false;}
			 if (Turn == 7)
			 {button3->Text = "X";
			 Turn++;
			 button3->Enabled = false;}
			 if (Turn == 8)
			 {button3->Text = "O";
			 Turn++;
			 button3->Enabled = false;}
			 if (Turn == 9)
			 {button3->Text = "X";
			 Turn++;
			 button3->Enabled = false;}
		 }


private: System::Void button4_Click(System::Object^  sender, System::EventArgs^  e) {
			 if (Turn == 1)
			 {button4->Text = "X";
			 Turn++;
			 button4->Enabled = false;}
			 if (Turn == 2)
			 {button4->Text = "O";
			 Turn++;
			 button4->Enabled = false;}
			 if (Turn == 3)
			 {button4->Text = "X";
			 Turn++;
			 button4->Enabled = false;}
			 if (Turn == 4)
			 {button4->Text = "O";
			 Turn++;
			 button4->Enabled = false;}
			 if (Turn == 5)
			 {button4->Text = "X";
			 Turn++;
			 button4->Enabled = false;}
			 if (Turn == 6)
			 {button4->Text = "O";
			 Turn++;
			 button4->Enabled = false;}
			 if (Turn == 7)
			 {button4->Text = "X";
			 Turn++;
			 button4->Enabled = false;}
			 if (Turn == 8)
			 {button4->Text = "O";
			 Turn++;
			 button4->Enabled = false;}
			 if (Turn == 9)
			 {button4->Text = "X";
			 Turn++;
			 button4->Enabled = false;}
		 }
private: System::Void button5_Click(System::Object^  sender, System::EventArgs^  e) {
			 if (Turn == 1)
			 {button5->Text = "X";
			 Turn++;
			 button5->Enabled = false;}
			 if (Turn == 2)
			 {button5->Text = "O";
			 Turn++;
			 button5->Enabled = false;}
			 if (Turn == 3)
			 {button5->Text = "X";
			 Turn++;
			 button5->Enabled = false;}
			 if (Turn == 4)
			 {button5->Text = "O";
			 Turn++;
			 button5->Enabled = false;}
			 if (Turn == 5)
			 {button5->Text = "X";
			 Turn++;
			 button5->Enabled = false;}
			 if (Turn == 6)
			 {button5->Text = "O";
			 Turn++;
			 button5->Enabled = false;}
			 if (Turn == 7)
			 {button5->Text = "X";
			 Turn++;
			 button5->Enabled = false;}
			 if (Turn == 8)
			 {button5->Text = "O";
			 Turn++;
			 button5->Enabled = false;}
			 if (Turn == 9)
			 {button5->Text = "X";
			 Turn++;
			 button5->Enabled = false;}
		 }
private: System::Void button6_Click(System::Object^  sender, System::EventArgs^  e) {
			 if (Turn == 1)
			 {button6->Text = "X";
			 Turn++;
			 button6->Enabled = false;}
			 if (Turn == 2)
			 {button6->Text = "O";
			 Turn++;
			 button6->Enabled = false;}
			 if (Turn == 3)
			 {button6->Text = "X";
			 Turn++;
			 button6->Enabled = false;}
			 if (Turn == 4)
			 {button6->Text = "O";
			 Turn++;
			 button6->Enabled = false;}
			 if (Turn == 5)
			 {button6->Text = "X";
			 Turn++;
			 button6->Enabled = false;}
			 if (Turn == 6)
			 {button6->Text = "O";
			 Turn++;
			 button6->Enabled = false;}
			 if (Turn == 7)
			 {button6->Text = "X";
			 Turn++;
			 button6->Enabled = false;}
			 if (Turn == 8)
			 {button6->Text = "O";
			 Turn++;
			 button6->Enabled = false;}
			 if (Turn == 9)
			 {button6->Text = "X";
			 Turn++;
			 button6->Enabled = false;}
		 }
private: System::Void button7_Click(System::Object^  sender, System::EventArgs^  e) {
			 if (Turn == 1)
			 {button7->Text = "X";
			 Turn++;
			 button7->Enabled = false;}
			 if (Turn == 2)
			 {button7->Text = "O";
			 Turn++;
			 button7->Enabled = false;}
			 if (Turn == 3)
			 {button7->Text = "X";
			 Turn++;
			 button7->Enabled = false;}
			 if (Turn == 4)
			 {button7->Text = "O";
			 Turn++;
			 button7->Enabled = false;}
			 if (Turn == 5)
			 {button7->Text = "X";
			 Turn++;
			 button7->Enabled = false;}
			 if (Turn == 6)
			 {button7->Text = "O";
			 Turn++;
			 button7->Enabled = false;}
			 if (Turn == 7)
			 {button7->Text = "X";
			 Turn++;
			 button7->Enabled = false;}
			 if (Turn == 8)
			 {button7->Text = "O";
			 Turn++;
			 button7->Enabled = false;}
			 if (Turn == 9)
			 {button7->Text = "X";
			 Turn++;
			 button7->Enabled = false;}
		 }
private: System::Void button8_Click(System::Object^  sender, System::EventArgs^  e) {
			 if (Turn == 1)
			 {button8->Text = "X";
			 Turn++;
			 button8->Enabled = false;}
			 if (Turn == 2)
			 {button8->Text = "O";
			 Turn++;
			 button8->Enabled = false;}
			 if (Turn == 3)
			 {button8->Text = "X";
			 Turn++;
			 button8->Enabled = false;}
			 if (Turn == 4)
			 {button8->Text = "O";
			 Turn++;
			 button8->Enabled = false;}
			 if (Turn == 5)
			 {button8->Text = "X";
			 Turn++;
			 button8->Enabled = false;}
			 if (Turn == 6)
			 {button8->Text = "O";
			 Turn++;
			 button8->Enabled = false;}
			 if (Turn == 7)
			 {button8->Text = "X";
			 Turn++;
			 button8->Enabled = false;}
			 if (Turn == 8)
			 {button8->Text = "O";
			 Turn++;
			 button8->Enabled = false;}
			 if (Turn == 9)
			 {button8->Text = "X";
			 Turn++;
			 button8->Enabled = false;}
		 }
private: System::Void button9_Click(System::Object^  sender, System::EventArgs^  e) {
			 if (Turn == 1)
			 {button9->Text = "X";
			 Turn++;
			 button9->Enabled = false;}
			 if (Turn == 2)
			 {button9->Text = "O";
			 Turn++;
			 button9->Enabled = false;}
			 if (Turn == 3)
			 {button9->Text = "X";
			 Turn++;
			 button9->Enabled = false;}
			 if (Turn == 4)
			 {button9->Text = "O";
			 Turn++;
			 button9->Enabled = false;}
			 if (Turn == 5)
			 {button9->Text = "X";
			 Turn++;
			 button9->Enabled = false;}
			 if (Turn == 6)
			 {button9->Text = "O";
			 Turn++;
			 button9->Enabled = false;}
			 if (Turn == 7)
			 {button9->Text = "X";
			 Turn++;
			 button9->Enabled = false;}
			 if (Turn == 8)
			 {button9->Text = "O";
			 Turn++;
			 button9->Enabled = false;}
			 if (Turn == 9)
			 {button9->Text = "X";
			 Turn++;
			 button9->Enabled = false;}
		 }
};
}
are you serious man? Nobody's gonna read all of that
@quirky, yes, some people will look over all that... but only if they get specifics...

You say it doesn't work, but could you be more specific? What doesn't work? Are you getting any errors?
@quirky, actually you barely have to read any of it. pretty much all of my buttons are the same, and the stuff after #pragma endregion is the stuff I wrote. the stuff above that is just so that it will create the form correctly if you paste it into C++ editor (Create a new form (Win32 application in visual C++ and paste it into the form1.h file).

@packetpirate, im sorry i can't really be much more specific on the problem. the program i have right now uses buttons to represent the board. the only variable i have is a turn variable (if turn is an odd number, x goes on the button clicked, if even then o). my program is bassically a bunch of identical if statements for each button, which is why there is so much code. each button is disabled and given text of either 'x' or 'o' once it is clicked. Once again, if you look right after the #pragma endregion section, you will see the load function. there i put the win condition, so if at any time during the game any of the conditions are met it will end.

So all in all, its really simple code and i have no errors, but i cannot figure out why it wont work (when i click on the buttons nothing happens???)

thanks for your interest
Topic archived. No new replies allowed.