Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Visual Basic ( VB ) (http://www.go4expert.com/forums/visual-basic/)
-   -   Arraylist searching troubles (http://www.go4expert.com/forums/arraylist-searching-troubles-t8078/)

CaJack 2Jan2008 18:28

Arraylist searching troubles
 
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?

pradeep 2Jan2008 23:29

Re: Arraylist searching troubles
 
Try replacing
Code: VB

Dim q As String = frm_EnterInfo.TextBox1.Text

with
Code: VB

Dim q As String = cStr(frm_EnterInfo.TextBox1.Text)



All times are GMT +5.5. The time now is 16:51.