Name
InStrRev Function
Class
Microsoft.VisualBasic.Strings
Syntax
InstrRev(stringcheck, stringmatch[, start[, compare]]
)
-
stringcheck
Use: Required
Data Type: String
The string to be searched.
-
stringmatch
Use: Required
Data Type: String
The substring to be found within
stringcheck
.-
start
Use: Optional
Data Type: Numeric
The starting position of the search. If no value is specified,
start
defaults to 1.-
compare
Use: Optional
Type:
CompareMethod
enumerationA constant indicating how
stringcheck
andstringmatch
should be compared.
Return Value
Long
Description
Determines the starting position of a substring within a string by searching from the end of the string to its beginning
Rules at a Glance
While
InStr
searches a string from left to right,InStrRev
searches a string from right to left.The
compare
argument can be one ofCompareMethod.Binary
(for a case-sensitive search) orCompareMethod.Text
(for a case-insensitive search). Ifcompare
is omitted, the type of comparison is binary. Note thatOption
Compare
is not used, unlike with theInStr
function.start
designates the starting point of the search as counted from the start ofstringcheck
. To start the search at the end ofstringcheck
, either omit thestart
argument or set it to -1.If
stringmatch
is not found,InStrRev
returns 0.If
stringmatch
is found withinstringcheck
, the value returned byInStrRev
is the position ofstringcheck
from the start of the string.
Example
This example uses both InStr
and
InStrRev
to highlight the different ...
Get VB .NET Language in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.