IsInArray - Check for value in an array
Submitted by justin on Wed, 02/18/2009 - 15:42
There have been many occassions where I've needed to check for a given value within an array in VBScript. There's no built-in function for this, so I crafted my own.
Function IsInArray(strIn, arrCheck)
'IsInArray: Checks for a value inside an array
'Author: Justin Doles - www.DigitalDeviation.com
Dim bFlag bFlag = False
If IsArray(arrCheck) AND Not IsNull(strIn) Then
Dim i
For i = 0 to UBound(arrCheck)
If LCase(arrcheck(i)) = LCase(strIn) Then
bFlag = True
End If
Next
End If
IsInArray = bFlag
End Function
Usage: If IsInArray(value, array) Then
WScript.Echo "Yes"
End If