InStrRev Function


InStrRev Function

Class

Microsoft.VisualBasic.Strings

Syntax

     Dim result As Integer = InStrRev(stringCheck, stringMatch[, _         start[, compare]]) 


stringCheck (required; String)

The string being searched.


stringMatch (required; String)

The substring to be found within stringCheck.


start (optional; Numeric)

The 1-based starting position for the search. If omitted, -1 is used, which indicates the last character of the string. Although the counting is done from the left end of the string, the search uses the character at that position and proceeds to the left.


compare (optional; CompareMethod enumeration)

The type of string comparison. One of the following Microsoft.VisualBasic.CompareMethod enumeration values.

Value

Description

Binary

Performs a binary (case-sensitive) comparison

Text

Performs a text (case-insensitive) comparison


If omitted, Binary is used.

Description

Finds the 1-based starting position of the last occurrence of stringMatch within stringCheck, optionally skipping the last few characters. If a match is not found, zero is returned. The search is done from the specified character position (the last character by default) and proceeds toward the left, the beginning of the string.

Usage at a Glance

  • The syntax of InStrRev is different from InStr.

  • While InStr searches a string from left to right, InStrRev searches a string from right to left.

Example

This example uses both InStr and InStrRev to highlight the different results produced by each.

     Dim bigString As String = _        "I like the functionality that InStrRev gives."     MsgBox(InStr(bigString, "th"))      ' Displays 8     MsgBox(InStrRev(bigString, "th"))   ' Displays 26 

See Also

InStr Function




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net