Help on Tic Tac Toe game/ new member

Okay, so I'm new to the forums (and C++) and I want to say hi!

I am making a Tic Tac toe game for a final project in my programming camp. I have an issue: I want to make the program so that it checks for wins and losses automatically and adds it to the win box. It is for 2 players with no option for AI, as I am not that experienced yet.

I have tried making an if statements but it always makes an error. I know that putting it in a private box it would not work.
This is what I am trying to get to work.
1
2
3
4
5
	if ((this-> pictureBox1 -> Visible = true) && (this-> pictureBox2 -> Visible = true) && (this-> pictureBox3 -> Visible = true))
	 {
		 textBox12->Text +="I";
	 }
		


What syntax could I add to add this feature? I'd really appreciate it if someone could help! I'm using Microsoft Visual C++ 2010 Express on windows forms application.



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#pragma once
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <iostream>
#include <string>
#include "Form1.h"


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;

	
#pragma endregion
	private: System::Void button7_Click(System::Object^  sender, System::EventArgs^  e) {
				 pictureBox4 -> Visible = true;
			 }
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
				pictureBox1 -> Visible = true;
		 }
private: System::Void textBox1_TextChanged(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
			 pictureBox10 -> Visible = true;
		 }
private: System::Void textBox2_TextChanged(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void button3_Click(System::Object^  sender, System::EventArgs^  e) {
			 pictureBox2 -> Visible = true;
		 }
private: System::Void button4_Click(System::Object^  sender, System::EventArgs^  e) {
			pictureBox11 -> Visible = true;
		 }
private: System::Void textBox3_TextChanged(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void button5_Click(System::Object^  sender, System::EventArgs^  e) {
			 pictureBox3 -> Visible = true;
		 }
private: System::Void button6_Click(System::Object^  sender, System::EventArgs^  e) {
			 pictureBox12 -> Visible = true;
		 }
private: System::Void textBox6_TextChanged(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void button8_Click(System::Object^  sender, System::EventArgs^  e) {
			pictureBox13 -> Visible = true; 
		 }
private: System::Void textBox4_TextChanged(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void button9_Click(System::Object^  sender, System::EventArgs^  e) {
			pictureBox5 -> Visible = true;			 
		 }
private: System::Void button10_Click(System::Object^  sender, System::EventArgs^  e) {
			 pictureBox14 -> Visible = true;
		 }
private: System::Void textBox5_TextChanged(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void button12_Click(System::Object^  sender, System::EventArgs^  e) {
			pictureBox6 -> Visible = true; 
		 }
private: System::Void button13_Click(System::Object^  sender, System::EventArgs^  e) {
			pictureBox15 -> Visible = true;
		 }
private: System::Void textBox7_TextChanged(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void button14_Click(System::Object^  sender, System::EventArgs^  e) {
			pictureBox7 -> Visible = true; 
		 }
private: System::Void button15_Click(System::Object^  sender, System::EventArgs^  e) {
			pictureBox16 -> Visible = true;
		 }
private: System::Void textBox8_TextChanged(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void button16_Click(System::Object^  sender, System::EventArgs^  e) {
			pictureBox8 -> Visible = true;
		 }
private: System::Void button17_Click(System::Object^  sender, System::EventArgs^  e) {
			pictureBox17 -> Visible = true;
		 }
private: System::Void textBox9_TextChanged(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void button11_Click(System::Object^  sender, System::EventArgs^  e) {
			 pictureBox9 -> Visible = true;
		 }
private: System::Void button18_Click(System::Object^  sender, System::EventArgs^  e) {
			 pictureBox18 -> Visible = true;
		 }
private: System::Void button19_Click(System::Object^  sender, System::EventArgs^  e) {
			pictureBox1 -> Visible = false;
			pictureBox2 -> Visible = false;
			pictureBox3 -> Visible = false;
			pictureBox4 -> Visible = false;
			pictureBox5 -> Visible = false;
			pictureBox6 -> Visible = false;
			pictureBox7 -> Visible = false;
			pictureBox8 -> Visible = false;
			pictureBox9 -> Visible = false;
			pictureBox10 -> Visible = false;
			pictureBox11 -> Visible = false;
			pictureBox12 -> Visible = false;
			pictureBox13 -> Visible = false;
			pictureBox14 -> Visible = false;
			pictureBox15 -> Visible = false;
			pictureBox16 -> Visible = false;
			pictureBox17 -> Visible = false;
			pictureBox18 -> Visible = false;
		 }
private: System::Void button20_Click(System::Object^  sender, System::EventArgs^  e) {
			 exit(0);
		 }
private: System::Void label2_Click(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void label3_Click(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void label1_Click(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void textBox10_TextChanged(System::Object^  sender, System::EventArgs^  e) {

		 }
private: System::Void button21_Click(System::Object^  sender, System::EventArgs^  e) {
			 textBox10->Text +="I";
		 }
private: System::Void textBox11_TextChanged(System::Object^  sender, System::EventArgs^  e) {

		 }
private: System::Void button22_Click(System::Object^  sender, System::EventArgs^  e) {
			  
		 }
private: System::Void textBox12_TextChanged(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void button23_Click(System::Object^  sender, System::EventArgs^  e) {
			  textBox12->Text +="I";
		 }
private: System::Void textBox13_TextChanged(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void button24_Click(System::Object^  sender, System::EventArgs^  e) {
			  
		 }
private: System::Void pictureBox1_Click(System::Object^  sender, System::EventArgs^  e) {
			
		 }
private: System::Void pictureBox2_Click(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void pictureBox3_Click(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void pictureBox4_Click(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void pictureBox5_Click(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void pictureBox6_Click(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void pictureBox7_Click(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void pictureBox8_Click(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void pictureBox9_Click(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void pictureBox10_Click(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void pictureBox11_Click(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void pictureBox12_Click(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void pictureBox13_Click(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void pictureBox14_Click(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void pictureBox15_Click(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void pictureBox16_Click(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void pictureBox17_Click(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void pictureBox18_Click(System::Object^  sender, System::EventArgs^  e) {
		 }

	
	if ((this-> pictureBox1 -> Visible = true) && (this-> pictureBox2 -> Visible = true) && (this-> pictureBox3 -> Visible = true))
	 {
		 textBox12->Text +="I";
	 }
		
		
};
}
Last edited on
if syntax:
if (a==b) {
...
}
tried it it still did not work. it still gives me a error
1>c:\users\student\desktop\projects\tic tac toe\tic tac toe\Form1.h(942): error C2059: syntax error : 'if'
1>c:\users\student\desktop\projects\tic tac toe\tic tac toe\Form1.h(943): error C2334: unexpected token(s) preceding '{'; skipping apparent function bo
at the end i see you closing (with { ) twice but i only seen you opening it once
and i believe that it isn't working because the if isn't in any function.
and i believe dmbman and jctech are also from that camp ? am i right :p?
Hallo,
See in your error output:
1>c:\users\student\desktop\projects\tic tac toe\tic tac toe\Form1.h(942): error C2059: syntax error : 'if'
1>c:\users\student\desktop\projects\tic tac toe\tic tac toe\Form1.h(943): error C2334: unexpected token(s) preceding '{'; skipping apparent function bo
The error is in your local header "Form1.h" on line 942. Included in your code in line 7.

Check it to see what's the problem or Post the related code, ok ?

I don~t know none about win app forms, but it isn't c#?
no we are using c++ and no that was not the problem still get the same two errors and gelatine they are in my same camp and i tried taking it off but i got a new error when that happened and i put it back and the error went away. i guess it is suppose to be like that
anybody??
It's c++.NET from the looks of it, which I have no idea why people think that's a good thing to teach. My high school taught that in it's C++ class, and it confused the hell out of me because I was already at least familiar with standard C++, so it just added another layer of confusion. Not to mention, going from that to standard was pretty weird.

Anyway, this threads not about hating on microsoft. So, what's your question? Have you done the things the others here have said? Have you looked at From1.h? That seems to be where the issue is at
I guess the the } on line 180 is wrong.
I guess the the } on line 180 is wrong.


That looks fine. Goes with the opening bracket for that function (Event? I don't even know. It has an opening bracket with it though.)

Wait. Line 189 - 190. First off, I dont think that bracket for 190 goes with anything. And 189, don't think there should be a ; there. Namespaces don't end with semi colons.

http://www.cplusplus.com/doc/tutorial/namespaces/
actually ResidentBiscuit i fixed it! i used the bottons i already placed and used
[codeprivate: System::Void button18_Click(System::Object^ sender, System::EventArgs^ e) {
pictureBox18 -> Visible = true;
if ((pictureBox12-> Visible) && (pictureBox15-> Visible) && (pictureBox18-> Visible))
{
textBox12->Text+="I";
}
if ((pictureBox10-> Visible) && (pictureBox14-> Visible) && (pictureBox18-> Visible))
{
textBox12->Text+="I";
}
if ((pictureBox16-> Visible) && (pictureBox17-> Visible) && (pictureBox18-> Visible))
{
textBox12->Text+="I";
}
}][/code]

i had to shorten it and then make it in bottons to check it
Topic archived. No new replies allowed.