Split2 – A Split variant that parses multiple lines of text

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 linesFunction 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)        Next    Next            Split2 = res()    End Function

See also  Is Machine Learning Automating Creativity in Graphic Design?

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist