473,395 Members | 1,885 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Tic-Tac-Toe

I'm sure this is a basic idea that I'm just not getting but.... I'm creating a two-player Tic-Tac-Toe game. I have my interface set up and a few of the functions finished. My question is how do I go about writing the code to decide whether to put an X or an O in the box based upon whose turn it is? I've used textboxes and set the control for click, I'm just not sure how to tell the program which player is clicking the box. I'm new to VB and just need to be pointed in the right direction. Thanks for your help.
Nov 10 '07 #1
2 1829
kadghar
1,295 Expert 1GB
... My question is how do I go about writing the code to decide whether to put an X or an O in the box based upon whose turn it is?
...
Thanks for your help.
define a Boolean and each time you click on a button switch it. when its true put an X, when is false put an O

[CODE)vb]dim boo1 as boolean

private sub command1_click()
boo1=not boo1
if boo1=true then
msgbox "X"
else
msgbox "O"
end if
end sub[/code]

HTH
Nov 10 '07 #2
Worked perfectly, thanks!!

define a Boolean and each time you click on a button switch it. when its true put an X, when is false put an O

[CODE)vb]dim boo1 as boolean

private sub command1_click()
boo1=not boo1
if boo1=true then
msgbox "X"
else
msgbox "O"
end if
end sub[/code]

HTH
Nov 10 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Daniel Bowett | last post by:
I have just started playing around with MySQLdb for a project I am planning. As a test I have written a script that executes 3000 insert statements on a table. The table contains 10 fields with a...
18
by: davineastley | last post by:
Hello, My name is Davin Eastley and I'm 13 years old. I live in Tasmania, Australia and am training for MCAD Certification in C#. I was interested to know what the best resources for learning...
12
by: WindAndWaves | last post by:
Hi Gurus I am sorry to ask so many questions, but unfortunately, you are just such an awesome source of knowledge that I can not help myself but ask lots. One day, I hope to be able to answer...
4
by: Jim Heavey | last post by:
I am wanting to find any instance in a string where more then on occurance of a value occurs and replace it with a single occurance of the value. Specifically I want to search a text field and find...
10
by: Chao | last post by:
I've been trying to develop some numerical codes with python, however got disappointed. A very simple test, a = 1.0 for i in range(1000): for j in range(1000): a = a+1
3
by: Arielle | last post by:
Greetings! I'm using classic ASP and an insert statement to save bulletin messages to a database that can be updated or viewed later. At first I thought it worked perfectly so I took some sample...
2
by: cylin | last post by:
Hi, I am currently doing a project regarding image processing. I had facing problem writing C++ code to calculate time taken to execute a function. Can somebody help me on this. thanks. ...
15
by: Sampat | last post by:
Hi, I wanted to know the performance of calling a function pointer v/s a normal function call in javascript in a scenario where there are multiple calls in the js to the same function. Please...
2
by: chokcheese | last post by:
I'm having trouble with a java application. When I try and run the program it shows a java.lang.NullPointerException in the "tic.getClient().getClientTicketList().add(tic);" line (it's in bold). I...
83
by: liketofindoutwhy | last post by:
I am learning more and more Prototype and Script.aculo.us and got the Bungee book... and wonder if I should get some books on jQuery (jQuery in Action, and Learning jQuery) and start learning about...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.