3

I am very new to ASP, it is far from my language of choice, and is completely out of my comfort zone.

I have two arrays, and I need to determine easily if a value from the first array exists in the second array. How would I do this? I am not sure what to even search for!

I did create a function to determine if a value exists in an array, but thats as far as I can get:

Function in_array(element, arr)
    For i=0 To Ubound(arr) 
        If Trim(arr(i)) = Trim(element) Then 
            in_array = True
            Exit Function
        Else 
            in_array = False
        End If  
    Next 
End Function 
Josh Crozier
  • 233,099
  • 56
  • 391
  • 304
Barry Chapman
  • 6,690
  • 3
  • 36
  • 64

1 Answers1

4

Luckily, I was able to figure this out through a small bit of work, using my previous function!

Here is the solution for those interested:

Function in_array(element, arr)
    For i=0 To Ubound(arr) 
        If Trim(arr(i)) = Trim(element) Then 
            in_array = True
            Exit Function
        Else 
            in_array = False
        End If  
    Next 
End Function 

Function array_in_array(arr1, arr2)

    For i=0 To Ubound(arr1) 
        If in_array(arr1(i), arr2 ) Then 
            array_in_array = True
            Exit Function
        Else 
            array_in_array = False
        End If  
    Next 

End Function 
Barry Chapman
  • 6,690
  • 3
  • 36
  • 64