Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

How to find a value is present in array without looping ?

e.g.
For i=1 TO ubount(Array)
  Find if value is present
Next

or some more direct statement like

Array.contains(somevalue) like in java
share|improve this question

1 Answer 1

up vote 1 down vote accepted

Writing your own function to do that really isn't that hard:

Function ARRContainsValue(arrValues() As String, ByVal sValue As String) As Logical

Dim i As Integer

ARRContainsValue = false

    For i = 1 To Ubound(arrValues)
        If arrValues(i) = sValue Then
            ARRContainsValue = true
            Exit Function       
        End if  
    Next

End Function

Note that this only works with String based arrays. You would need to write specific functions for each array types (Integer, Date, etc)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.