help with tic tac toe game code

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hello everyone, im coding a simple tic tac toe game for one of my computer science class. Im having a bit of trouble getting my check win sub routine to work. I keep getting this error: "Conversion from string "TrueFalseFalse" to type Boolean is not valid.".
Here is my code for the sub routine:
<pre class="prettyprint lang-vb Private Sub checkwin()

If (btn1.Text = "X") & (btn2.Text = "X") & (btn3.Text = "X") Then MsgBox("X WINS!")
If (btn4.Text = "X") & (btn5.Text = "X") & (btn6.Text = "X") Then MsgBox("X WINS!")
If (btn7.Text = "X") & (btn8.Text = "X") & (btn9.Text = "X") Then MsgBox("X WINS!")
If (btn1.Text = "X") & (btn4.Text = "X") & (btn7.Text = "X") Then MsgBox("X WINS!")
If (btn2.Text = "X") & (btn5.Text = "X") & (btn8.Text = "X") Then MsgBox("X WINS!")
If (btn3.Text = "X") & (btn6.Text = "X") & (btn9.Text = "X") Then MsgBox("X WINS!")
If (btn1.Text = "X") & (btn5.Text = "X") & (btn9.Text = "X") Then MsgBox("X WINS!")
If (btn3.Text = "X") & (btn5.Text = "X") & (btn7.Text = "X") Then MsgBox("X WINS!")

If (btn1.Text = "O") & (btn2.Text = "O") & (btn3.Text = "O") Then MsgBox("O WINS!")
If (btn4.Text = "O") & (btn5.Text = "O") & (btn6.Text = "O") Then MsgBox("O WINS!")
If (btn7.Text = "O") & (btn8.Text = "O") & (btn9.Text = "O") Then MsgBox("O WINS!")
If (btn1.Text = "O") & (btn4.Text = "O") & (btn7.Text = "O") Then MsgBox("O WINS!")
If (btn2.Text = "O") & (btn5.Text = "O") & (btn8.Text = "O") Then MsgBox("O WINS!")
If (btn3.Text = "O") & (btn6.Text = "O") & (btn9.Text = "O") Then MsgBox("O WINS!")
If (btn1.Text = "O") & (btn5.Text = "O") & (btn9.Text = "O") Then MsgBox("O WINS!")
If (btn3.Text = "O") & (btn5.Text = "O") & (btn7.Text = "O") Then MsgBox("O WINS!")


End Sub[/code]
<br/>
Can any of you guys help me out? Thanks!

View the full article
 
Back
Top