troubleshooting Question

VB.NET beginner question regarding an array - sample code/error provided >_<

Avatar of ouch_mybrain_
ouch_mybrain_ asked on
.NET ProgrammingVisual Basic.NET
3 Comments1 Solution298 ViewsLast Modified:
Hello Experts,

I am a beginner who is trying to learn I need some help in understanding why I am getting an error when trying to check if a variable exists against an array (see below):

Here is my code ... also please note that on my form I have a button called "Button1" and a text box called "txtBoxGuess". The idea is that I enter a character into the textbox and then press the button. If the character exists in the string then I get a message saying "hooray!", and if it is not in the array, "boo".

Public Class Form1

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

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGuess.Click

        Dim sport(6) As String
        sport(0) = "c"
        sport(1) = "r"
        sport(2) = "i"
        sport(3) = "c"
        sport(4) = "k"
        sport(5) = "e"
        sport(6) = "t"

        Dim Guess As String
        Guess = txtBoxGuess.Text

        If sport.Contains = Guess Then
        End If
    End Sub
End Class


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros