InStr

concerns

The InStr function returns the position where a string is found within another string.

 

Syntax

InStr([Start, ] SearchIn, SearchFor [, Comp] )

Return value

Type

Description

Long

The position in SearchIn

Parameter

Use

Name

Type

Passing

Description

Optional

Start

Long

ByVal

Starting position of the search.

Required

SearchIn

String

ByVal

The string to be searched in

Required

SearchFor

String

ByVal

The string to be searched for

Optional

Comp

Long

ByVal

Comparison mode: default 0

 

Possible return values

0

-     SearchIn has length 0

-     SearchFor has length 0

-     Start > length of SearchIn

-     SearchFor is not part of SearchIn

> 0

The position of SearchFor in SearchIn

 

The Start parameter sets the start position of the search. If  Start is not specified, the search starts automatically at the first character of the specified string. Please note that you must use the Start parameter if you use the Comp parameter! The search in the string is done from left to right.

SearchIn specifies the string to search, where SearchFor is the string to search for.

Use the Comp parameter to specify the type of comparison:

 

Comp

Description

0

Binary compare

1

Text based compare (Upper- and lower case are ignored)