Promotic
WikipediaLinkedInYoutubeTwitterFacebook

InStr - function of language VBScript

Description:
Returns the position of the first occurrence of one string within another.

For the purposes of PROMOTIC system, it is more usefull to use the method: Pm.StringFind.

Syntax:
InStr([start As Integer], string1 As String, string2 As String, [compare As Integer]) As Integer
Calling:
n = InStr([start,] string1, string2[, compare])
Parameters:
start[optional] (Integer) Numeric expression that sets the starting position for each search. If omitted, search begins at the first character position. The start argument is required if compare is specified.
string1(String) String expression being searched
string2(String) String expression searched for
compare[optional] (Integer) Numeric value indicating the kind of comparison to use when evaluating substrings. If omitted, a binary comparison is performed.
vbBinaryCompare - perform a binary comparison
vbTextCompare - perform a textual comparison
Return Values:
0 - string1 is zero-length or string2 is not found or start > Len(string2)
Null - string1 or string2=Null
start - string2 is zero-length
position at which match is found - string2 is found within string1
Note:
The InStr function is used with byte data contained in a string. Instead of returning the character position of the first occurrence of one string within another, InStr returns the byte position.
Example:
Dim SearchString, SearchChar, nPos
SearchString ="XXpXXpXXPXXP"
SearchChar = "P"
nPos = InStr(4, SearchString, SearchChar, 1) 'A textual comparison starting at position 4, returns 6
nPos = InStr(1, SearchString, SearchChar, 0) 'a binary comparison starting at position 1, returns 9
nPos = InStr(SearchString, SearchChar) 'binary comparison, returns 9
nPos = InStr(1, SearchString, "W") 'a binary comparison starting at position 1, returns 0 ("W" is not found)
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice