Jonny
Jonny

Reputation: 97

VB.net -ArrayLists issues with searching

I'm probably just overcomplicating things...

Both of the arrays I'm using are arrayLists, what I'm trying to do is, most/all of array1 will be in array2, array1 however holds 5 digits strings and array2 (also strings) has a longer string which possibly starts with the first 5 digits of array1.

So if that makes sense, what I'm trying to do is using array1's each string, searching array2 for it and when found, I want the whole string, and I'm going to create a new arraylist for those.

I'm not sure what's slipping me up! .Contains seems to not find anything in array2, even though array1 has say "00111" and array2 has "00111, FIND for 8043890132", I'm guessing that's because it's looking for exactly "00111"?

      For Each unfoundLo In arrUnfoundInLo           

                 If arrCorList.IndexOf(unfoundLo) Then      '

Upvotes: 0

Views: 867

Answers (1)

the_lotus
the_lotus

Reputation: 12748

I'm not sure from what I see but I assume you are only doing one loop.

You'll have to loop in both array

For Each item1 In array1
    For Each item2 In array2
        If item2.Contains(item1) Then

Or loop array two, get the number part

For Each item2 In array2
    numberPart = item2.SubString(0, 5)

    If array1.Contains(numberPart) Then

* These are example, not actual code to use

Upvotes: 1

Related Questions