Tuesday, August 10, 2010

Visual Basic String Function : InStrRev

Purpose : The InstrRev function returns the position of an occurrence of a search string within another string being searched ; it is similar to the IsStr function . However, unlike the InStr function, which search from left to right, InStrRev searches the string from right to left.

Syntax :
InStrRev ( strString1 , strString2 [ , IngStartPos [ , compare ] ] )

strString1 : String in which to search for strString2.
strString2 : String to be searched.
IngStartPos : Position in strString1 from which to start the search for strString2
compare : Numeric value indicating the kind of comparison to use when evaluating FindValue against the InputStr array. default value is vbBinaryCompare
0 : vbBinaryCompare
1 : vbTextCompare
2 : VbDatabaseCompare

Dim strBye as String
Dim ingPos as Integer
strBye = "Good Bye"

ingPos = (InStrRev ( strBye , "Bye" )

The argument strString1 is the string that will be searched. strstring2 is the string that is being searched for. If srrString2 is found within strString1 , InStrRev returns the position where the beginning of the search string is found . If the string cannot be found , a 0 is returned.

No comments:

Post a Comment