Find the starting position of the last occurrence of a sub string within a string. ( With strings, the first character is at position 1 )
Dim s
s = "QuickTest Professional quicktest professional"
' ** The following 4 lines are case-sensitive
Print InStrRev( s, "Professional" ) ' Prints 11
Print InStrRev( s, "QuickTest" ) ' Prints 1
Print InStrRev( s, "QUICKTEST" ) ' Not found, Prints 0
Print InStrRev( s, "professional" ) ' Prints 34
' ** The following 3 lines are case-insensitive
' ** The 3rd argument is the starting position from the end of the string.
' ** This should be set to -1 to search the entire string from the end to beginning.
Print InStrRev( s, "professional", -1, vbTextCompare ) ' Prints 34
Print InStrRev( s, "quicktest", -1, vbTextCompare ) ' Prints 24
Print InStrRev( s, "QUICKTEST", -1, vbTextCompare ) ' Prints 24
Posted in VBScript

daniva




Recent Comments