VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Is in Array Function

by Brian Gillham (7 Submissions)
Category: VB function enhancement
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (7 Votes)

Find if a value exists in an array WITHOUT LOOPING. Often we need to find out if a value exists in an array. This one does it VERY FAST.
NOTE: This Function only return True / False regarding the Existence of a Value. If you need the Index you will have to LOOP.

Rate Is in Array Function

Public Function IsInArray(FindValue As Variant, arrSearch As Variant) As Boolean
 On Error GoTo LocalError
 If Not IsArray(arrSearch) Then Exit Function
 If Not IsNumeric(FindValue) Then FindValue = UCase(FindValue)
 IsInArray = InStr(1, vbNullChar & Join(arrSearch, vbNullChar) & vbNullChar, vbNullChar & FindValue & vbNullChar) > 0
Exit Function
LocalError:
 'Justin (just in case)
End Function

Download this snippet    Add to My Saved Code

Is in Array Function Comments

No comments have been posted about Is in Array Function. Why not be the first to post a comment about Is in Array Function.

Post your comment

Subject:
Message:
0/1000 characters