InStr                                                                                                          Function

 

INSTR(start as integer, s as string, pattern as string, type as integer)

 

Description

Searches string s starting at position start to find the string pattern.If type is 0 then a search for an exact match of case and pattern occurs. If type is 1, then a case insensitive search is conducted.  It returns an integer result which is 0 if pattern is not found in string s or an integer which is the position within string s where the pattern was found.

 

Example

Dim s as string

Dim result as integer

s="abcdef"

result=InStr(1, s, "cde", 0) 'would return result=3

result=InStr(1, s, "CDE", 0) 'would return 0 because of case difference

result=InStr(1, s, "CDE", 1) 'would return 3 because case is ignored