by Evan Miller (2 Submissions)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Mon 4th March 2002
Date Added: Mon 8th February 2021
Rating:
(1 Votes)
This code will take a delimited string and pass back a sub array of elements.
Dim strArr() As String
Dim strOutputString As String
Dim intStart As Integer
Dim intEnd As Integer
Dim I As Integer
On Error GoTo ErrorHandler
If p_strInput = "" Then Exit Function
strArr = Split(p_strInput, p_strDelim, , vbBinaryCompare)
If p_intStartElement <> 0 Then intStart = p_intStartElement - 1
If p_intLength = 0 Then
intEnd = MyUbound(strArr)
Else
intEnd = intStart + p_intLength - 1
End If
'Re-assemble the array
For I = intStart To intEnd
strOutputString = strOutputString & strArr(I) & p_strDelim
Next
If Right$(strOutputString, Len(p_strDelim)) = p_strDelim Then
strOutputString = Left$(strOutputString, Len(strOutputString) - Len(p_strDelim))
End If
ReturnSubArray = strOutputString
Exit Function
ErrorHandler:
ReturnSubArray = p_strInput
End Function
Function MyUbound(p_strArr() as string) as Long
On Error Goto ErrorHandler
MyUbound = Ubound(p_strArr)
Exit Function
ErrorHandler:
MyUbound = -1
end function
No comments have been posted about This code will take a delimited string and pass back a sub array of elements.. Why not be the first to post a comment about This code will take a delimited string and pass back a sub array of elements..