Chat LIVE With Programming Experts! There Are 23 Online Right Now...

Welcome to Dream.In.Code
Become a VB Expert!

Join 244,258 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,282 people online right now. Registration is fast and FREE... Join Now!




Tic Tac Toe with Text Boxes

 
Reply to this topicStart new topic

Tic Tac Toe with Text Boxes

piefork
1 Dec, 2008 - 09:52 PM
Post #1

New D.I.C Head
*

Joined: 1 Dec, 2008
Posts: 4


My Contributions
Hey, I am fairly new to Visual Basic and for an assignment I have to program a two player tic tac toe using text boxes as the squares.

The problem I am having is that it won't declare on the if statement who won, even though the variables are working correctly.

CODE
Private Sub cmdcheck_Click()
Dim victory1, victory2, victory3, victory4, victory5, victory6, victory7, victory8 As String

victory1 = txttopleft.Text & txttopright.Text & txttopmiddle.Text
victory2 = txttopleft.Text & txtmiddle.Text & txtbottomright.Text
victory3 = txttopright.Text & txtmiddle.Text & txtbottomleft.Text
victory4 = txttopleft.Text & txtmiddleleft.Text & txtbottomleft.Text
victory5 = txttopmiddle.Text & txtmiddle.Text & txtbottommid.Text
victory6 = txttopright.Text & txtmiddleright.Text & txtbottomright.Text
victory7 = txtmiddleleft.Text & txtmiddle.Text & txtmiddleright.Text
victory8 = txtbottomleft.Text & txtbottommid.Text & txtbottomright.Text

If (victory1 = xxx) Or (victory2 = xxx) Or (victory3 = xxx) Or (victory4 = xxx) Or (victory5 = xxx) Or (victory6 = xxx) Or (victory7 = xxx) Or (victory8 = xxx) Then
Picture1.Print "X WINS!"
ElseIf (victory1 = ooo) Or (victory2 = ooo) Or (victory3 = ooo) Or (victory4 = ooo) Or (victory5 = ooo) Or (victory6 = ooo) Or (victory7 = ooo) Or (victory8 = ooo) Then
Picture1.Print "O WINS!"
End If
End Sub


any suggestions would be greatly appreciated, thank you.

User is offlineProfile CardPM
+Quote Post


piefork
RE: Tic Tac Toe With Text Boxes
2 Dec, 2008 - 08:36 AM
Post #2

New D.I.C Head
*

Joined: 1 Dec, 2008
Posts: 4


My Contributions
QUOTE(the clit commander @ 2 Dec, 2008 - 08:24 AM) *

well like this
it took me like 2 mins to do
and guess what i aint gunna tell you!!!
hahahahah



Your "help" is appreciated, but I have to use text boxes, as it states in my project.
User is offlineProfile CardPM
+Quote Post

oXiDe
RE: Tic Tac Toe With Text Boxes
2 Dec, 2008 - 09:58 AM
Post #3

New D.I.C Head
*

Joined: 17 Nov, 2007
Posts: 37



Thanked: 1 times
My Contributions
put the ooo's and xxx's in quotes like "xxx" and "ooo" really simple >:D
also this line
CODE
Dim victory1, victory2, victory3, victory4, victory5, victory6, victory7, victory8 As String

its declaring victory1 thru victory7 as object.. this is ok i guess but it would perhaps be better if you declared them each as a string like this
CODE
Dim victory1 As String, victory2 As String, victory3 As String, victory4 As String, victory5 As String, victory6 As String, victory7 As String, victory8 As String

User is offlineProfile CardPM
+Quote Post

piefork
RE: Tic Tac Toe With Text Boxes
2 Dec, 2008 - 10:13 AM
Post #4

New D.I.C Head
*

Joined: 1 Dec, 2008
Posts: 4


My Contributions
this worked, thank you so much.

left you a thank comment for your help.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 7/4/09 11:18AM

Live VB Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month