ItemArrayPos Function:
Check to see if element exists and return the position in the array.
Description:
ItemArrayPos Function check to see if element exists and return the position in the array.
Syntax:
Int = ItemArrayPos(someElement, someArray)
Example:
<%
Dim someArray(9), someElement someArray(0) = "Paul" someArray(1) = "John" someArray(2) = "Richard" someArray(3) = "James" someArray(4) = "George" someArray(5) = "Michael" someArray(6) = "Robert" someArray(7) = "Daniel" someArray(8) = "Raymond" someArray(9) = "Kevin"
someElement = "Robert"
Response.Write ItemArrayPos(someElement, someArray) & "<br />" '--- returns: 6
%>
ASP Source Code:
<%
Public Function ItemArrayPos(ByRef someElement, ByRef someArray) Dim i If InStr(Join(someArray), someElement) > 0 Then For i = 0 To Ubound(someArray) If someElement = someArray(i) then ItemArrayPos = i End if Next End If End Function
%>
|