InStrRev Function [VBA]
Devolve a posição de uma cadeia dentro de outra cadeia, com início no lado direito da mesma.
A função InstrRev devolve a posição na qual foi encontrada a correspondência, a iniciar na direita. Se a cadeia não for encontrada, a função devolve 0.
InStrRev (Text1 As String, Text2 As String [,Start As Long] [, Compare As Integer])
Longo
Texto1: expressão da cadeia de caracteres que pretende procurar.
Texto2: expressão da cadeia de caracteres que pretende procurar.
Start: Optional numeric expression that marks the position from the left in a string where the search for the specified substring starts. If you omit this parameter, the search starts at the last character of the string. The maximum allowed value is 65535.
Compare: Optional numeric expression that defines the type of comparison. The value of this parameter can be
1: The default value of 1 specifies a text comparison that is not case-sensitive.
0: The value of 0 specifies a binary comparison that is case-sensitive.
To avoid a run-time error, do not set the Compare parameter if the first return parameter is omitted.
Sub ExamplePosition
Dim sInput As String
Dim iPos As Integer
sInput = "The book is on the table"
iPos = InStrRev(sInput,"the",10,1) ' Returns 1, search is case-insensitive
Print iPos
iPos = InStrRev(sInput,"the",10,0) ' Returns 0, search is case-sensitive
Print iPos
End Sub