Jump to content
  • Advertisement
Sign in to follow this  

Naughts and Crosses- VB.NET

This topic is 3935 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
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!