<< Prev        Next >>

ID : 757

InStrRev

Function

Start searching a designated string (string2) in any string (string1) from the end of the character position, then return the character position of the string (number of characters from the beginning to the character) when it appears first.

Syntax

InStrRev(string1, string2[, start])

Guaranteed entry

string1
Designate string type data for search field.
string2
Designate string type data for search.
start
Designate integer type data for setting start position of search. "-1" will be applied when abbreviating argument "start" to start searching from the end of the characters.

Return value

Start searching a designated string (string2) in any string (string1) from the end of the character position, then return the character position of the string (number of characters from the beginning to the character) by integer type data when it appears first.

Description

Start searching a designated string (string2) in any string (string1) from the end of the character position, then return the character position of the string (number of characters from the beginning to the character) when it appears first.

Designating the third argument start should be done at the character position counted from the beginning (left) of the string.

Related Terms

InStr, Mid, Right, String Function

Attention

This is case sensitive.

The syntax is different from Function InStr's one.

Example

'!TITLE "Sample of InStrRev"

Sub Sample_InStrRev 

  Dim aaa As String
  aaa = "ABCD-CDEF-ABCD-FFFF"
  PrintDbg Mid(aaa,InStrRev(aaa, "-") + 1) ' print "FFFF"
  PrintDbg Mid(aaa,InStrRev(aaa, "-", Len(aaa) - 5) + 1, 4) ' print "ABCD"
  

End Sub

ID : 757

<< Prev        Next >>