0

hi everyone. I have two array, array1 is two dimension and array2 is one dimension. I want to compare each number in array1 to array2 and if the number is not existing in array2 i want to add this number to array2. I am using vb.net2010. please help me

2
Contributors
2
Replies
11
Views
2 Years
Discussion Span
Last Post by batoolhussain
0

Make two nested loops, 1st loop to go through Array1 and 2nd loop to go through Array2 for comparing.

For i as Integer = 0 to Array1.GetUpperBound(0)
    Dim comp As Boolean = False

    For j as integer = 0 to Array2.GetUpperBound(0)
        If Array2(j)=Array1(i) Then
            comp = True
            Exit For
        End If
    Next

    If comp then
        Redim Preserve Array2(Array2.GetUpperBound(0) + 1)
        Array2(Array2.GetUpperBound(0)) = Array1(i)
    End If
Next

Hope it can help you

0

thank you very much for answer me but i solve the problem and my solve is exactly your solve and it work

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.