borderAndreaVB free resources for Visual Basic developersborder

AndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2008 Andrea Tincani
:: Find if a value exists in an Array

Author  

Brian Gillham

Language  

VB6

Operating Systems  

Windows 95, 98 and NT
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
:: Navigation

Home

Beginners Corner

Previous Tip

Next Tip

:: Search this site
Google
:: Related Topics
icon 21-06-2005 Re: How can print PDF file automatically? by skuller
icon 08-04-2005 Re: check if FOLDER exist and if its EMPTY OR NOT? by JLRodgers
icon 02-03-2005 Text file to MDB table by panik!
icon 20-02-2005 Re: need help in data display by Goran
icon 06-01-2005 Re: Adding Data in a table with relationships using ADO by Goran
Partners: Il portale per lui e lei | Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2008 Andrea Tincaniborder