Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: VB6,VBS
Expertise: Intermediate
Apr 1, 2000



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Split2 - A Split variant that parses multiple lines of text

' A Split variant that parses a string that contains
' row and column separators, and returns a 2-dimensional array
' the result String array has a number of columns equal
' to the highest number of fields in individual text lines

Function Split2(ByVal Text As String, Optional ByVal RowSeparator As String = _
    vbCrLf, Optional ByVal ColSeparator As String = ",") As String()
    Dim lines() As String
    Dim cols() As String
    Dim r As Long
    Dim c As Long
    ' first, split the string in lines
    lines() = Split(Text, RowSeparator)
    ' initialize the result array
    ' start with just one column
    ReDim res(UBound(lines), 0) As String
    ' parse each line of text
    For r = 0 To UBound(lines)
        cols() = Split(lines(r), ColSeparator)
        ' resize the result array if necessary
        If UBound(cols) > UBound(res, 2) Then
            ReDim Preserve res(UBound(lines), UBound(cols)) As String
        End If
        ' copy the individual values
        For c = 0 To UBound(cols)
            res(r, c) = cols(c)
    Split2 = res()
End Function
Francesco Balena
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date