Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 131,602 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 2,030 people online right now. Registration is fast and FREE... Join Now!




Counter

 
Reply to this topicStart new topic

Counter, Tic Tac Toe

VBb/cIhv2
post 8 May, 2005 - 12:11 PM
Post #1


New D.I.C Head

*
Joined: 1 May, 2005
Posts: 13

Ok VB gods I call upon your assistance. I am making a tic tac toe game, that does not play the computer, 2 player only. I have started by making one frame separated by six lines making a tic tac toe box. I have put two buttons per square one labeled x and the other labeled o also I have put two pictures behind them and made their visibility = false on form load. I put the buttons in using a control array. Now I am stuck I can't figure out for the life of me how to make a counter that will get this thing workin.blink.gif I need it to be able to declare a winner also. Please help. Thank-you Thank-you. By the way the code snippet worked great thank-you.
User is offlineProfile CardPM

Go to the top of the page


IainMackay85
post 8 May, 2005 - 02:34 PM
Post #2


New D.I.C Head

*
Joined: 7 May, 2005
Posts: 44


My Contributions


use an array:
Dim winner[5] as Integer
now on form load do
i = o
While i<6
winner[i] = -1
end while

that'll set all the values of the array to -1
think of it like:

-1 -1 -1
-1 -1 -1
-1 -1 -1

now in all the buttons do
eg for the top left x button do
winner[0] = 0
and for the top left 0 button do
winner[0] = 1

and also do
dim xwinner1[5] = {1,0,0,0,1,0,0,0,1} <- think of it as
1 0 0
0 1 0
0 0 1
and do the same for all the possible winning combos

then test if winner = xwinner1 etc on each button press, you could make some fun use of the CASE functions.

Hope this helps Iain
User is offlineProfile CardPM

Go to the top of the page

skyhawk133
post 9 May, 2005 - 12:47 AM
Post #3


Head DIC Head

Group Icon
Joined: 17 Mar, 2001
Posts: 14,829



Thanked 45 times

Dream Kudos: 1650

Expert In: Web Development

My Contributions


Iain, welcome to dream.in.code, thank you for helping out! It's great to see new talent around here, especially in the VB forum!

From myself and the rest of the dream.in.code team, we welcome both of you to dream.in.code! Thanks again!
User is offlineProfile CardPM

Go to the top of the page

Acid Reign
post 9 May, 2005 - 01:54 AM
Post #4


Touched by his noodly appendage

*****
Joined: 11 Nov, 2002
Posts: 2,123



Dream Kudos: 2
My Contributions


using 2 buttons in each place is inefficent and causes problems.

a better way would be to change the text attribute of a single box for each place.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/20/08 04:06AM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month