Find if a value exists in an Array in VB6.0

Unknown | 9:00 AM |

Module:

Option Explicit

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

Usage:

Private Sub Command1_Click()
Dim x(5) As String

x(0) = 5
x(1) = 100
x(2) = 2000
x(3) = 11
x(4) = 7
x(5) = 1010
MsgBox IsInArray(10, x)
End Sub

Category:

About http://dotnetvisual.blogspot.in/:
DOT NET TO ASP.NET is a web application framework marketed by Microsoft that programmers can use to build dynamic web sites, web applications and web services. It is part of Microsoft's .NET platform and is the successor to Microsoft's Active Server Pages (ASP) technology. ASP.NET is built on the Common Language Runtime, allowing programmers to write ASP.NET code using any Microsoft .NET language. create an application very easily ....