Sorry, my bad. The firstArray wasn't pulling the right results.
ArrayList.Contains works perfectly well =)

On Jul 31, 9:02 am, Ana Drumond <[email protected]> wrote:
> Hi,
>
> I’m developing is ASP.NET/VB.NET. I’m having problems while searching for an
> element in an ArrayList. What I have is:
>
> *firstArray*: it’s an ArrayList; contains strings; each string in this array
> will be concatenated with the string in the *MyCheckBoxlist*; its size is
> 161
>
> *MyCheckBoxList*: its size is 5
>
> secondArray: it’s an ArrayList; contains string; its values are being
> retrieve from the Database; its size is 866
>
> What I’m doing is: each element of *firstArray* is concatenated with each
> element of *MyCheckBoxList*; then I check if the result of this
> concatenation is found in the *secondArray*; if so I remove this element
> from *secondArray*.
>
> The problem is: In theory, the result of looping through the two for loops
> should delete 161 x 5 = 805 elements from *secondArray* (I checked both
> arrays and they are with the correct elements). But what I have in the end
> of both loops is a totally different result: only 152 elements are being
> deleted from *secondArray*. I’m debugging and there’s a point where
> *str*exists in the
> *secondArray*, but *secondArray.Contains(str)* is false. Does anyone have
> any idea about what is happening? I can’t figure it out!! I appreciate any
> help. Thanks in advance for all replies!
>
> Follows my code:
>
> Dim myCount As Integer = 0
>
>             For w As Integer = 0 To firstArray.Count - 1
>
>                 Dim currentStr As String = firstArray.Item(w)
>
>                 If currentStr.Contains("myString") Then
>
>                     type = "type1"
>
>                 Else
>
>                     type = "type2"
>
>                 End If
>
>                 For z As Integer = 0 To MyCheckBoxList.Items.Count - 1
>
>                     Dim str As String = type + currentStr +
> MyCheckBoxList.Items(z).
>
>                     If secondArray.Contains(str) = True Then
>
>                         secondArray.Remove(str)
>
>                         myCount = myCount + 1
>
>                     End If
>
>                 Next
>
>             Next
>
> Ana

Reply via email to