VB 6 included a useful Split function that allowed you to convert delimited text (ie portions of text broken up by a certain character) into an array. This code shows you how to make one if you do not have VB 6. Pass a string, and a delimiter, and it will return an array containing each item between the delimiter.
Private Function Split(Expression As String, Optional Delimiter As String)
As Variant
Dim i As Long
Dim lNextPos As Long
Dim sText As String
Dim lCount As Long
Dim varTemp() As String
For i = 1 To Len(Expression)
lNextPos = InStr(i + 1, Expression,
Delimiter)
If lNextPos = 0 Then
lNextPos
= Len(Expression) + 1
End If
sText = Mid$(Expression, i, lNextPos
- i)
ReDim Preserve varTemp(lCount)
varTemp(lCount) = sText
lCount = lCount + 1
i = lNextPos + Len(Delimiter) - 1
Next
Split = varTemp
End Function
Comments