Written By TheVBProgramer.
PROGRAMMING EXERCISE
Tic-Tac-Toe
Write a VB application that will enable a human player to play a classic game of Tic-Tac-Toe against the computer.
The application should begin with a form that contains the following elements:
- A label saying "Welcome to Tic-Tac-Toe"
- Two option buttons enclosed in a frame. The captions for the option buttons should be "X" and "O". The caption for the frame should be "Select 'X' or 'O' and click OK".
- A command button with the caption "OK".
When the user clicks OK, exit this form and display the main form (the game board).
At the start of each game, the application should select who should go first at random, and display an appropriate message to the user in a message box (either "You go first this time." or "This time, I will go first.")
The game board should be set up with an array of label controls indexed 0 through 8. When a player clicks one of the available labels, an "X" or an "O" (depending on the user's initial selection) should appear in that label. Then the computer should make its move.
When the program detects a win, a line should be drawn through the "three in a row". If the player wins, the message "YOU WIN !!!" should flash across the game board; if the computer wins, the message "YOU LOSE!!!" (or "I WIN!!!" or "COMPUTER WINS!!!") should flash across the game board. If the game ends in a tie, the message "IT'S A TIE!!!" should flash across the game board. (Hint: To get the flashing message, use a label in conjunction with a timer and toggle the label's Visible property on and off.)
The program should provide options to play a new game and to quit.
The program should provide keep four counts: games played, games won, games lost, and games tied. These counts should be displayed on the form.
The overall appearance of the application should be tasteful and suggest "fun". Experiment with various colors and fonts until you get it the way you want it.
Your program should implement the following algorithm to try to make the computer win:
(1) Examine the board for a winning move, and if you find one, make that move – otherwise proceed to step (2).
(2) Examine the board to see if your opponent has a winning move, and if so, select that square to block, otherwise proceed to step (3).
(3) If the center square is available, select it, otherwise proceed to step (4).
(4) If you are already occupying the center square, and a side square is available, take the side square, otherwise proceed to step (5).
(5) If a corner square is available, then take it, otherwise, take the next available square.
Note: When the above algorithm is implemented, it is possible for a smart player to beat the computer if the player is able to go first. If you switch steps (4) and (5), it may be impossible for a player to win; the best they can do is tie.
Tic-Tac-Toe
(screenshots of my version of the solution)



Download the solution for this project here.
cool
its great pls send me the code its urgent
Code
Please sent the code to my email! magwurtz@cox.net
Thank you!
Great game .
can you give me the codes of this game ,
I gonna use it for my school projects.
send the codes in this email address . jaspher_casungcad@yahoo.com.
Thx :)
tic tac toe code
Can you please send me a copy of the code for this game. thaks.
code please
please send me a code of tic tac toe of visual basic 6 plsssssssss....this is my email thunder_emperor85@y.c
code
pls send me the code...10q...
hi
can i have the code of tic tac toe???we really need this one,,,tnx
source code for matrix processor
Sir, my name is henry, i want to make a matrix processor of (A*B,A-B,A+B) ,and i need a source code for this program
so i could learn more,i will really appreciate if you can help me using visual basics.Thanks.pls send it to my email on
henry_agunu@yahoo.com.God bless you,i need it for my project .
pls send me code plsssssssssss!
pls send me code of this game i want for my project as early as possible plssssssss send me now
plz look at the end of last print short here on this page for so
"Download the solution for this project here."
just click here and get the solution
can u help me???
can u plz send the source code ?...
plzzzzzzzzz........
i need it for our project really badly..
here's my email add: mizty_zue_08@yahoo.com
HELP ME PLEASE!! :(
PLEASE SEND ME THE CODES. THIS IS FOR MY PROJECT IN COMPUTER... SEND ME THE CODES PLEASE! my email is koreanovela_addictus@yahoo.com.ph
THANK YOU :D
the code
Hi plsssss send to me the codes of this tic tac toe game. tnx! :))
my email is daniel123_94talob@yahoo.com
gud day plz send me a code
gud day plz send me a code of tic tac toe this is my email dhatzcompania@yahoo.com
codes
kindly send to me the codes ??i need it for my case study.. plssss.. thanks a lot
hi
good day!
can u plz send the code???
this is my account mae.gellesania@yahoo.com
Tnx and god bless
God
God Bless??????????????????????????????????
i need this code
would you be so kind to send me that code at evans.nikita@rocketmail.com thanks
i need this code..can u
i need this code..can u please view your codes or send it to my email at jess_gurl1112@yahoo.com.ph..thanks
Hi, it's super, I m also
Hi,
it's super, I m also develop some game so The source code will help to appriciate and understand itw workings more
chansvar@gmail.com
thank u
i really need this code
i really need this code please email me @ jeffrey_lavarro@yahoo.com
thnx
i need vb6 code in this tic
i need vb6 code in this tic tac toe pls send my email argelmoreno@yahoo.com..thank you!
Are you too lazy to read the
Are you too lazy to read the article? There is a link to a zipped file containing the code at the end of the article.
PlZZZZZZZz
can u send me the codes?? i just really need it for my project
please send me the codes
please send this programs code, and i will appreciate it very much. my email address Ramseymunyua@yahoo.com. thank you.
plz
i really need the coding for this. my email is ac_Dcjacob@hotmail.com thanx
Please
i need this one for my project... thank you
i'am interested with this 1..
I'm interested with this kind of program...
please send me the codes of this program at my email add...
annvendi20@yahoo.com
thanks a lot vb6.us clan
plz send me vb6 code of
plz send me vb6 code of tictac toe
name
The name says it all.
Regarding Tic tac toe game.
I want to get the source code (in C++)of Tic-tac-toe game.In this game the player is supposed to play with computer and should always loose.It means that computer must always wins.
Can u please get it for me!!!!
Thanxs.
How to make game tic tac toe with 2 player??
I have project from my lecturer,,,
that is game tic tac toe with 2 player,,
you can help me??
can you give me source code dari game tic tac toe with visual basic 6.0..
i wish,,,it,,,
thank's.. ^^
hi, can u please send me
hi,
can u please send me the code to this game. my email is sports_freak_2011@yahoo.com
thank you.
The Source code is at the
The Source code is at the bottom....
But it's...
But the source code is labeled as "Solution" Just click the link and then download the zip file.
please give the codes of tictactoe
can you please give the codes of tictactoe!!!
please send it to my email:
holy_boy07@yahoo.com
hi!
can u please give the code for the tictac toe..
please..
i need it badly..
email the code to me..
here is my email address
angeluzh_26@yahoo.com
Please send me the code..My
Please send me the code..My e-mail ID is lak104@gmail.com..Thanks..
can i have the source code
can i have the source code for this game plz
Hay How You Doing? I Was
Hay How You Doing? I Was Wounder Could You Please Send Me The Code To This Game To jjperkins2007@yahoo.com
can you send me these codes
Hi can you send me those codes please i realy like that and i want to study them more!!!
i need that code
can u please send me the code.. i want to study that code..THANXX..
freak_throy@yahoo.com
please send me the code/project
I'm learning game programming right now, and I'm doing it for my campus' task, can you send me the code and the project please. thank you
my em-mail : tekunofuriku@gmail.com
please
please send me this codes needed in this program.......... please!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
SCCT
SKYSTAR COLLEGE OF 'C'INFORMATION TECHNOLOGIES
Please
can u please send me this game and how to make it with codes and all thanx heaps...
send it to Josh_bentley_27@hotmail.com
ssst
pls send me the code my email is dark_khent@yahoo.com
could you?!
could you please send me the code for the tic tac toe..or could you please send me the file itself so that i could have the whole copy of the program? Thnx
hi
can i ask for the codes? pls send 8 2 my email add.
cuz..8s already wonderfull,and i want to try 8!
thankS!
PLZZZ SEND ME THE CODE OF
PLZZZ SEND ME THE CODE OF THIS PROGRAM MY EMAIL IS swastikaconan@yahoo.com
AS SOON AS AUGUST 2009 TY......
I need d source code in vb
Hi,
Its realy wonderfu. I would really love to have the source code in Visual Basic for this fine tic tac toe game. The source code will help to appriciate and understand itw workings more.
my email addre is urssincerelyolise@yahoo.com
thank you.
it's cool
please send me the source codes i love to learn..(chathuridias@ymail.com)
thank u
hello
plzzzzzzzzzzzz send me the code of this game on scorpionwafa@yahoo.com pleaseeeeeeeeeeeeeeeeeeeeeeeeeeee
hello
plzzzzzzzzzzzz send me the code of this game on scorpionwafra@yahoo.com pleaseeeeeeeeeeeeeeeeeeeeeeeeeeee
tic
I have no idea why everyone keeps asking for the code when it's clearly there!
The thing I like about your project is how amazingly tidy and more importantly efficient your code is. I was programming my own tictactoe game and came across this one. Mine had fairly much the same layout, except you can't choose whether you will be x's or o's, as x always goes first. But that said, I have masses of code in comparison, and I haven't even started coded the procedure for the computer to calculate it's move.
That said, I used images rather than labels for the game board, which although it looks nicer, it didn't help my code.
However I wasn't at all impressed by the layout or colour scheme. It's too bright and colourful and gives a tacky design impression, it should be toned down or faded IMO. It looks like your typical '90's homemade website!
However it's still a nice program, and very well programmed, and I learned a few things from your code that will come in useful.
I would be happy to share mine when it's complete if you wanted a look?
Could you please send me
Could you please send me this code as well. Its much appreciated!
Thanks!!
Can I please have the code
Can I please have the code to this game? I suck at computer science and my grade depends on it. thankx
Do you have code for VB8?
Do you have code for VB8?
The code
the code can be found in the area that says: ...Download the solution for this project here.......
Pls send me the code
Pls send me the code..thanks
can you please send me also
can you please send me also the code?
can i have that code?
can i have the code of that program?
please, send it to my email address..
thanks! :))
Hi
Hi sir can i ask how did you come up with that game im a die hard fan of game makers and dreamed of being a game creator someday. . Can i also have a code of the tic tac toe so i could study it and learn more. . thank you so much. . heres my email sir elhgameaccount@yahoo.com
P.S: your the man. . hope i could be like you someday. .
i really dont see why u guys
i really dont see why u guys keep asking for the code i mean theres the source right in fornt of u!!!
pls....
send me the code of tic tac toe game in visual basic6.0
vb6
can you kindly give the source code of this game plz.... for give me plz send this to paulo_red17@yahoo.com
hello cool game!
please send me the code thanks in advance
----> paasaawaay_daaw_aako@yahoo.com
hey send me the source code pls
please send me the code for this game using the following address: m4coi@yahoo.com
code
gnkHi nice article ,could you please forward me the code on visual basic 6.0 for this game tic tac toe on my e-mail id please as soon as possible
its very nice
can i have the code...?
pls send to this email.. ayhle_000@yahoo.com
Post new comment