InStr Function

Language Items List

Definition:

Returns the position of the first character in a string that is within another string being searched.

Syntax (1):

InStr[$]([start,] strexpr1, strexpr2)

Syntax (2):

InStr(start, strexpr1, strexpr2 [,compare])


Syntax Description


start Numeric expression that sets the position in the string at which the search is to begin. The value of start must be greater than 1. If start is not used, the search defaults to the first character of strexpr1. The start argument must be included if the compare argument is used.

strexpr1 String expression that is being searched.

strexpr2 String expression that is being searched for.

compare Optional argument that specifies the string-comparison method. The argument compare can be 0 or 1. If you do not use compare, the default string-comparison method is used, which is case-sensitive. If compare is used, start must be given.

If compare is 0, string comparison is case-sensitive. Case-sensitive means, for example, that an uppercase
T does not match a lowercase t. If compare is 1, string comparison is not case-sensitive, meaning the "T" and "t" are seen as the same.

Details:

If strexpr2 is found within strexpr1, InStr returns the position at which the string was found. If strexpr2 is zero-length, InStr returns start. InStr returns a 0 in three situations: if the specified string expression strexpr2 cannot be found, if start is greater than strexpr2, or if strexpr1 is zero-length.

See Also:

StrComp Function