Instr()

Top  Previous  Next

InStr() - Find a string within another

Description

The InStr() function returns the position of the first occurrence of one string within another.

InStr([start, ]haystack, needle[, compare])

Parameters
The optional start parameter specifies the position to start the search.

The haystack parameter is the string to be searched.

The needle parameter is the string to search for.

The optional compare parameter specifies the the method of comparison according to [id=43]this table[/id]. The start parameter is required if compare is specified.

Example

haystack = "The quick brown fox"

 

Result = InStr(haystack, "brown") 'returns 11

Result = InStr(haystack, "orange") 'returns 0 not found