Pos Procedure

Returns the position of a string sSubStr within another string sStr.

Syntax

[ lPos = ] Pos ( sSubStr, sStr, [lStart], [bCompareNoCase], [bReverseOrder] )

The Pos procedure syntax has the following parts:

Name

Type

Description

lPos

Long

Position of sSubStr in sStr

sSubStr

Val BString

The string to look for

sStr

Val BString

Where to look

lStart

Val Long

Optional. Start index. Default value is 0 for start from beginning of sStr.

bCompareNoCase

Val Bool

Optional. Default is False. When True, the sSubStr is searched ignoring upper/lower case differences. v11

bReverseOrder

ValBool

Optional. Look for the string in reverse order, specify -1 for lStart to search from the end of the string. v11

Comments

Note that the position of the string is zero-based.

This function returns the position of the first character of the string sSubStr within the string sStr starting from 0. If sSubStr is not found, the function returns -1. The search is case sensitive.

Example

i = Pos("Ea", "ATEasy")   ! now i = 2

i = Pos("A", "ATEATE", 1) ! now i = 3

i = Pos("A", "ATEasy", -1, True, True) ! now i = 3

 

See Also

Left, Len, Mid, Right