Jump to content
  • Advertisement
Sign in to follow this  
AncientHunter

Naughts and Crosses- VB.NET

This topic is 4061 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hey, i have a coding problem for the results of winning that is to stubborn to work! at the moment i have picture boxes for this two player game that show whether you have won, lost or drawn. the thing is its always draw until someone wins. i know what i have to do to get it right but its not working. pleaze help me.
Private Sub ResultWinner()
        Dim count As Integer
        If DetermineWinner() = 1 Then
            pic_DisplayResult2.Image = Image.FromFile(Application.StartupPath & "\Visual basic\You Win!.bmp")
            pic_DisplayResult.Image = Image.FromFile(Application.StartupPath & "\Visual basic\You Lose!.bmp")
            score1 += 100
            P1DisplayScore()
        ElseIf DetermineWinner() = 2 Then
            pic_DisplayResult.Image = Image.FromFile(Application.StartupPath & "\Visual basic\You Win!.bmp")
            pic_DisplayResult2.Image = Image.FromFile(Application.StartupPath & "\Visual basic\You Lose!.bmp")
            score2 += 100
            P2DisplayScore()
        Else
            For count = 1 To 9
                'arrPic(count) = nothing works everywhere else.  Why doesnt it work here?
                If arrPic(count) = Nothing Then
                Else
                    pic_DisplayResult.Image = Image.FromFile(Application.StartupPath & "\Visual basic\Draw.bmp")
                    pic_DisplayResult2.Image = Image.FromFile(Application.StartupPath & "\Visual basic\Draw.bmp")
                End If
            Next count

        End If
    End Sub



the line it doesnt like in this code is "If arrPic(count) = Nothing Then". it comes up with an error message saying "Error 1 Operator '=' is not defined for types 'System.Windows.Forms.PictureBox' and 'System.Windows.Forms.PictureBox'."

Share this post


Link to post
Share on other sites
Advertisement
I don't code in VB.NET, so this may not really be the correct solution.

Try doing
If arrPic(count) Is Nothing Then


Also, can you show me where/how you declare arrPic ?

EDIT:

Why not just do this?

For count = 1 To 9
'arrPic(count) = nothing works everywhere else. Why doesnt it work here?
If arrPic(count) IsNot Nothing Then
pic_DisplayResult.Image = Image.FromFile(Application.StartupPath & "\Visual basic\Draw.bmp")
pic_DisplayResult2.Image = Image.FromFile(Application.StartupPath & "\Visual basic\Draw.bmp")
End If
Next count

Share this post


Link to post
Share on other sites
that takes away the squigly lines but it does the same thing when run. here is where i stated arrPic:


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SetControlArray()
End Sub

Private Sub SetControlArray()
arrPic(1) = PictureBox1
arrPic(2) = PictureBox2
arrPic(3) = PictureBox3
arrPic(4) = PictureBox4
arrPic(5) = PictureBox5
arrPic(6) = PictureBox6
arrPic(7) = PictureBox7
arrPic(8) = PictureBox8
arrPic(9) = PictureBox9
End Sub


Share this post


Link to post
Share on other sites
Quote:
Original post by AncientHunter
that takes away the squigly lines


Which squiggly lines are you talking about?

Share this post


Link to post
Share on other sites
in VB.Net when it finds errors (some) it puts blue squigly lines under it to say that you screwed up something. that line is gone now but it still refuses to work.

Share this post


Link to post
Share on other sites
when i run the program? well as soon as i make a move for either player the picturebox shows a picture saying "DRAW" until someone wins and it changes to "win" or "lose"

Share this post


Link to post
Share on other sites
I still don't understand.

Can you explain what is supposed to happen?

Can you explain what actually happens?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!