Determine if a Value Exists in an Array without Looping

Category:
Lists, Collections and Arrays
Type:
Snippets
Difficulty:
Beginning
Author:
Brian Gillham

Version Compatibility: Visual Basic 6

More information:
This function is very handy for checking whether a value exists in an Array. Ordinarily most programmers will use the LBound / UBound values of an array to loop through the array. Well here is a fast way of checking the Array.

Notes: 1) The array must be declared as a string array or an array of variants. 2) This only works in VB6 because of the use of the Join function. If you have VB5, you can use the VB5 friendly join function at http://www.freevbcode.com/ShowCode.Asp?ID=489

Instructions: Copy the declarations and code below and paste directly into your VB project.

Declarations:

Code: