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,
startdefaults to 1.-
compare Use: Optional
Type:
CompareMethodenumerationA constant indicating how
stringcheckandstringmatchshould 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
InStrsearches a string from left to right,InStrRevsearches a string from right to left.The
compareargument can be one ofCompareMethod.Binary(for a case-sensitive search) orCompareMethod.Text(for a case-insensitive search). Ifcompareis omitted, the type of comparison is binary. Note thatOptionCompareis not used, unlike with theInStrfunction.startdesignates the starting point of the search as counted from the start ofstringcheck. To start the search at the end ofstringcheck, either omit thestartargument or set it to -1.If
stringmatchis not found,InStrRevreturns 0.If
stringmatchis found withinstringcheck, the value returned byInStrRevis the position ofstringcheckfrom the start of the string.
Example
This example uses both InStr and
InStrRev to highlight the different ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access