Implement VB6 string functions in VB5 (Improved Over MSKB Version)

Category:
String Manipulation
Type:
Modules
Difficulty:
Intermediate
Author:
Jay Duhon

Version Compatibility: Visual Basic 6, Visual Basic 5

More information:
Visual Basic 6 has five intrinsic string functions not available to programmers using Visual Basic 5: InStrRev, Join, Split, Replace, and Reverse.

The Microsoft Knowledge Base at http://support.microsoft.com/support/kb/articles/q188/0/07.asp was previously suggested on this site as a resource for implementing these functions in VB5. But if you look at Microsoft's implementation, you'll see why Microsoft C++ programmers shouldn't try to write Visual Basic code. ;)

I fixed their poorly written Join and Split functions. Join was doing something redundant with an error handler, and Split was unnecessarily split(!) into two functions.

I wrote a Replace function of my own that is a bit more robust than Microsoft's version, and won't put you in an endless loop if you do something like Replace(MyString, "", "T") or Replace(MyString, "T", "T").

Note: I didn't change the InStrRev or Reverse functions, but included them for the sake of completeness.

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

Declarations:

Code: