18.01.2013 Views

VBScript Reference Manual for InduSoft Web Studio

VBScript Reference Manual for InduSoft Web Studio

VBScript Reference Manual for InduSoft Web Studio

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>InduSoft</strong> <strong>Web</strong> <strong>Studio</strong> <strong>VBScript</strong> <strong>Reference</strong> <strong>Manual</strong><br />

InStrRev<br />

Description Returns the position of an occurrence of one string within another, from the end of string<br />

Usage intVal = InStrRev(string1, string2[, start[, compare]])<br />

Arguments string1<br />

Required. String expression being searched.<br />

string2<br />

Required. String expression searched <strong>for</strong>.<br />

start<br />

Optional. Numeric expression that sets the starting position <strong>for</strong> each search. If omitted, -1 is<br />

used, which means that the search begins at the last character position. If start contains Null,<br />

an error occurs.<br />

compare<br />

Optional. Numeric value indicating the kind of comparison to use when evaluating substrings.<br />

If omitted, a binary comparison is per<strong>for</strong>med. See Settings section <strong>for</strong> values.<br />

Settings The compare argument can have the following values:<br />

Constant Value Description<br />

vbBinaryCompare 0 Per<strong>for</strong>m a binary comparison.<br />

vbTextCompare 1 Per<strong>for</strong>m a textual comparison<br />

Return An integer value indicating the position<br />

InStrRev returns the following values:<br />

If InStr returns<br />

string1 is zero-length 0<br />

string1 is Null Null<br />

string2 is zero-length start<br />

string2 is Null Null<br />

string2 is not found 0<br />

string2 is found within string1 Position at which match is found<br />

start > Len(string2) 0<br />

Remarks Note: The syntax <strong>for</strong> the InStrRev function is not the same as the syntax <strong>for</strong> the InStr function.<br />

Note that with UniCode characters, the second byte is usually non-zero (e.g. Asian characters). If<br />

start is Null, a runtime error will occur. If start > Len(string2), 0 will be returned.<br />

See Also InStr, InStrB<br />

Example The following examples use the InStrRev function to search a string:<br />

Dim SearchString, SearchChar, MyPos<br />

SearchString ="XXpXXpXXPXXP" 'String to search in.<br />

SearchChar = "P" 'Search <strong>for</strong> "P".<br />

MyPos = InstrRev(SearchString, SearchChar, 10, 0) ‘Binary comparison. Returns 9.<br />

MyPos = InstrRev(SearchString, SearchChar, -1, 1) ‘Textual comparison. Returns 12<br />

MyPos = InstrRev(SearchString, SearchChar, 8) 'Comparison is binary. Returns 0.<br />

<strong>InduSoft</strong>, Ltd. 141

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!