InstrRev Function With Reverse Count Option

Category:
String Manipulation
Type:
Snippets
Difficulty:
Beginning
Author:
Bruno Di Rei Araujo

Version Compatibility: Visual Basic 6, Visual Basic 5

More information:
This is an InStrRev function that can be used in VB5 or VB6. It enhances the VB6 InStrRev function in that, if you set the fourth parameter to true, it will return the the position of the last occurrence of the substring relative to the end of the string as opposed to the beginning, e.g.,

l = InStrRev("Hello", "o", , True)

returns 1, whereas VB6's InstrRev function would return 5 if "o" is passed as the substring and Hello is passed as the search string. l = InStrRev

Instructions: Copy the declarations and code below and paste directly into your VB project.

Declarations:

Code: