Windows - Example inarray function, InArray Method

Example inarray function

The below example will explain you how the inarray function works. in_array function is used to check whether given string is available in an array or not.

<%
Function in_array(element, arr)
For i=0 To Ubound(arr)
If Trim(arr(i)) = Trim(element) Then
in_array = True
Exit Function
Else
in_array = False
End If
Next
End Function
str = "Blue"
colors = Array("Red","Green","Blue","Black","White")
If in_array(str,colors) Then
Response.Write str & " is in the array"
Else
Response.Write str & " is not in the array"
End If
%> 

The above example will check the given string "Blue" is available in an array or not.

The topic on Windows - Example inarray function is posted by - Maha

Hope you have enjoyed, Windows - Example inarray functionThanks for your time

Tech Bluff