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

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




Tic Tac toe Score Board

 
Reply to this topicStart new topic

Tic Tac toe Score Board

dingo190
26 Feb, 2008 - 05:35 AM
Post #1

New D.I.C Head
*

Joined: 26 Feb, 2008
Posts: 6



I'd been trying to make a score board when X or O win...
But when the Score only reach to 1 and can't go higher then 1..
how?
i dim Score1 as intger
Dim Score2 as intger

Nid Some help~







CODE
If lblLabel1.Text = "X" And lblLabel2.Text = "X" And lblLabel3.Text = "X" Then
            lblScore1.Text = Score1 + 1
            MessageBox.Show("PLAYER 1 is The WINNER~!~")

        ElseIf lblLabel4.Text = "X" And lblLabel5.Text = "X" And lblLabel6.Text = "X" Then
            lblScore1.Text = Score1 + 1
            MessageBox.Show("PLAYER 1 is The WINNER~!~")

        ElseIf lblLabel7.Text = "X" And lblLabel8.Text = "X" And lblLabel9.Text = "X" Then
            lblScore1.Text = Score1 + 1
            MessageBox.Show("PLAYER 1 is The WINNER~!~")

        ElseIf lblLabel1.Text = "X" And lblLabel4.Text = "X" And lblLabel7.Text = "X" Then
            lblScore1.Text = Score1 + 1
            MessageBox.Show("PLAYER 1 is The WINNER~!~")

        ElseIf lblLabel2.Text = "X" And lblLabel5.Text = "X" And lblLabel8.Text = "X" Then
            lblScore1.Text = Score1 + 1
            MessageBox.Show("PLAYER 1 is The WINNER~!~")

        ElseIf lblLabel3.Text = "X" And lblLabel6.Text = "X" And lblLabel9.Text = "X" Then
            lblScore1.Text = Score1 + 1
            MessageBox.Show("PLAYER 1 is The WINNER~!~")

        ElseIf lblLabel1.Text = "X" And lblLabel5.Text = "X" And lblLabel9.Text = "X" Then
            lblScore1.Text = Score1 + 1
            MessageBox.Show("PLAYER 1 is The WINNER~!~")

        ElseIf lblLabel7.Text = "X" And lblLabel5.Text = "X" And lblLabel3.Text = "X" Then
            lblScore1.Text = Score1 + 1
            MessageBox.Show("PLAYER 1 is The WINNER~!~")

        End If







        If lblLabel1.Text = "O" And lblLabel2.Text = "O" And lblLabel3.Text = "O" Then
            lblScore2.Text = score2 + 1
            MessageBox.Show("PLAYER 2 is The WINNER~!~")
        ElseIf lblLabel4.Text = "O" And lblLabel5.Text = "O" And lblLabel6.Text = "O" Then
            lblScore2.Text = score2 + 1
            MessageBox.Show("PLAYER 2 is The WINNER~!~")

        ElseIf lblLabel7.Text = "O" And lblLabel8.Text = "O" And lblLabel9.Text = "O" Then
            lblScore2.Text = score2 + 1
            MessageBox.Show("PLAYER 2 is The WINNER~!~")
        ElseIf lblLabel1.Text = "O" And lblLabel4.Text = "O" And lblLabel7.Text = "O" Then
            lblScore2.Text = score2 + 1
            MessageBox.Show("PLAYER 2 is The WINNER~!~")
        ElseIf lblLabel2.Text = "O" And lblLabel5.Text = "O" And lblLabel8.Text = "O" Then
            lblScore2.Text = score2 + 1
            MessageBox.Show("PLAYER 2 is The WINNER~!~")
        ElseIf lblLabel3.Text = "O" And lblLabel6.Text = "O" And lblLabel9.Text = "O" Then
            lblScore2.Text = score2 + 1
            MessageBox.Show("PLAYER 2 is The WINNER~!~")
        ElseIf lblLabel1.Text = "O" And lblLabel5.Text = "O" And lblLabel9.Text = "O" Then
            lblScore2.Text = score2 + 1
            MessageBox.Show("PLAYER 2 is The WINNER~!~")
        ElseIf lblLabel7.Text = "O" And lblLabel5.Text = "O" And lblLabel3.Text = "O" Then
            lblScore2.Text = score2 + 1
            MessageBox.Show("PLAYER 2 is The WINNER~!~")

        End If







User is offlineProfile CardPM
+Quote Post

Sonyaswan
RE: Tic Tac Toe Score Board
27 Feb, 2008 - 02:08 PM
Post #2

New D.I.C Head
*

Joined: 26 Feb, 2008
Posts: 4


My Contributions
this code is hurting my head... I'm sure there's a better way of writing it, but I guess for now I can show you where you've gone wrong...

CODE
lblScore1.Text = Score1 + 1
MessageBox.Show("PLAYER 1 is The WINNER~!~")


the score won't increase because you're not changing the value of the variable "score1"... you're just adding 1 to the variable and displaying it in a label... try this...

CODE
Score1 = Score1 + 1
lblScore1.Text = Score1
MessageBox.Show("PLAYER 1 is The WINNER~!~")

User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Tic Tac Toe Score Board
27 Feb, 2008 - 02:40 PM
Post #3

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,483



Thanked: 161 times
Dream Kudos: 9075
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
With the advent of VB.Net you now have the += operator available, which makes your incrementing much easier and cleaner, like this



vb

Score1 += 1
lblScore1.Text = Score1
MessageBox.Show("PLAYER 1 is The WINNER~!~")

User is offlineProfile CardPM
+Quote Post

dingo190
RE: Tic Tac Toe Score Board
29 Feb, 2008 - 02:46 AM
Post #4

New D.I.C Head
*

Joined: 26 Feb, 2008
Posts: 6

Thx for helping i go try out and see how ~ ^^ thx for reading...
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 09:33PM

Be Social

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

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month