Simple Split Function for VB5

Category:
String Manipulation
Type:
Snippets
Difficulty:
Beginning
Author:
Pavol "SCorp" Cierny

Version Compatibility: Visual Basic 6, Visual Basic 5

More information:
The Split function is an useful tool when you want to split a string by a character. Altough it isn't implemented in VB5, you can write your own.

Set splitChar parameter to the delimiter you want and str1 is the string you want to split; intPos is the position of the word in the string. The indexing is 0 based (or 1-based if you have Option Base 1 set).

Example: MsgBox Split(",", "This,is,a,test", 2) ' displays a

Note: There is another implementation of split for VB5 at http://www.freevbcode.com/ShowCode.Asp?ID=275.

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

Declarations:

Code: