InvalidcastException

cesar

New member
Joined
Sep 5, 2007
Messages
1
Programming Experience
Beginner
When I run this code I get an invalid cast exception

can someone help me fix this?

thanks in advance

VB.NET:
Private Sub PrintWinner()

        Try

            Dim objBoxes() As Object = {Me.lbl00.BackColor, Me.lbl01.BackColor, Me.lbl02.BackColor, Me.lbl10.BackColor, _
Me.lbl11.BackColor, Me.lbl12.BackColor, Me.lbl20.BackColor, Me.lbl21.BackColor, Me.lbl22.BackColor}

            If objBoxes(0) And objBoxes(1) And objBoxes(2) = Color.Crimson Then


                lblWinner.Text = "Computer Wins"


            End If
        Catch ex As Exception

            MessageBox.Show(ex.ToString())


        End Try
       

    End Sub
 
You want to check if (objBoxes(0)=Color.Crimson) and (objBoxes(1)=Color.Crimson) and (objBoxes(2)=Color.Crimson) ?
 
Back
Top