1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Arraylist searching troubles

Discussion in 'Visual Basic ( VB )' started by CaJack, Jan 2, 2008.

  1. CaJack

    CaJack New Member

    Joined:
    Mar 21, 2007
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    0
    I’m having some trouble with my array list. I’m using my array list to store numbers in it. Adding stuff to it works fine. But searching the array list to see if it already contains a number is proving more difficult. Here’s what I’ve got:
    Code:
    Public Sub TestNum()
            Dim p As String
            Dim q As String = frm_EnterInfo.TextBox1.Text
            For Each p In c_TestArrayClass.NumArray
    
                If p = q Then
    
                    frm_enterInfo.Label3.Text = "Found in Array"
                    Exit For
                Else
    
                    frm_enterInfo.Label3.Text = "Not Found"
    
                End If
            Next
       
        End Sub
    
    I get this error when I run it "Conversion from type 'EnterInfoClass' to type 'String' is not valid" and it points to this part:
    Code:
    For Each p In c_TestArrayClass.NumArray
    
    Could anyone help me?
     
  2. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,646
    Likes Received:
    86
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    Try replacing
    Code:
    Dim q As String = frm_EnterInfo.TextBox1.Text
    
    with
    Code:
    Dim q As String = cStr(frm_EnterInfo.TextBox1.Text)
    
     

Share This Page