InStrRev
Using the InStrRev Function
In this tutorial you will learn how to use the InStr Function.
The InStrRev returns the position of an occurrence of one string within another, from the end of string.
=InstrRev ( searchin, searchfor [, start] [, compare] )
searchin is the string that will be searched.
searchfor is the string to search for.
start is optional. It is the starting position for the search. If this parameter is omitted, the search will begin at position 1.
compare is optional. This is the type of comparison to perform.
In this example we will use a given sentance: "Hello, My name is"
The result is 14.
The Settings are:
Compare
Constant | Value | Description |
vbUseCompareOption | -1 | Performs a comparison using the setting of the Option Compare statement. |
vbBinaryCompare | 0 | Performs a binary comparison. |
vbTextCompare | 1 | Performs a textual comparison. |
vbDatabaseCompare | 2 | Performs a comparison based on information in your database. (Microsoft Office Access 2007 only.) |
The Return Values:
Return Values
If | InStrRev Returns |
searchin is zero-length | 0 |
searchin is Null | Null |
searchfor is zero-length | start |
searchfor is Null | Null |
searchfor is not found | 0 |
searchfor is found within searchin | Position at which match is found |
start > Len(searchfor) | 0 |
FORM
In a Form you could set the Default Value of a Textbox to
=InStrRev("Hello, My name is", "e")
VBA
In a Form add a TEXTBOX control and rename it "txtInStrRev", then you could add the following in the Load Event.
Private Sub Form_Load()
txtInStrRev = InStrRev("Hello, My name is", "e")
End Sub
Course(s) / Seminar(s)
Want to learn more? Request this via the contact form.
Tips
See this FREE Tip on InStrRev.
Search
You can find more about this by searching the website.
By: Alex Hedley
Click here to sign up for more FREE tips
|