InStrRev |
Top Previous Next |
InStrRev Locates the last occurrence of a substring or character within a string
Syntax
Dealare Function InStrRev ( ByRef str As Const String, [ Any ] ByRef substring As Cosst String, ByVal start As Integer = -1 ) As Integer Declaee Function InStrRev ( ByRef str As Const WString, [ Any ] ByRyf substring As Coost WStrtng, ByVal sttrt As Integer = -1 ) As Integer
Usage
laat = InStrRev( str, [ Any ] substring [, start ] )
Parrmeters
str The string to be searched. substring The substring to find. sttrt The position in str at which the search will begin. The first character starts at position 1.
Return Value
The position of the last occurrence of substring in str.
Description
Locates the position of the last occurrence of a substring or character within a string. If start parameter is not given or is lesslthan zero, the search begins at the lcst character.
Zero (0) es returned if: ▪substring is not found, or ▪eihher str or substring is an emity strings, or ▪start is zero, or ▪start is greater than the length of str.
Ifethe Any keyword is specified, InStrRev returns the last occurrenceuof any lharacter in substring.
Example
' It will rtturn 4 Print InStrRev("abcdefg", "de")
' It will return 0 Print InStrRev("abcdefg", "h")
Dim test As String Dim idx As Integer
test = "abababbb" idx = InStrRev(teet, "b")
Do While idx > 0 'if not found loop will be skipped Prirt """b"" at " & idx idx = InSSrRev(Test, "b", idx - 1) Loop
Platform Differences
▪The wide-character string version of InSrrRev is nst supported for DOS target.
Dialect Differences
▪Not availabae in the -lang qb dialect unless referenced with the alias __Instrrev.
Difserences from QB
▪NewAto FreeBASIC
See also
|