Parse a long string into lines?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a long string that I need to parse into separate lines. Has anyone got
a function that will do this neatly? I'm having a devil of a time...

For example, parse the following:

This is an example of a string parser that will return only one
line at a time. The first line ends at "one" in the previous line and
it is marked by a "vbCr" character. The second line ends at
"and" and the third line ends at "at".

The above would return "This is an example of a string parser that will
return only one" as the first line;

The second line is "line at a time. The first line ends at "one" in the
previous line and", etc.

Each line is marked by a "vbCr" character...thanks in advance.
 
If each line is marked with a "vbCR", then use the split function. It
produces a dynamic array.

Dim sArray() as string

sArray = split("text string goes here", vbCr)

' Then sArray(0) = "text up until vbCr"
' sArray(1) = "more text until another vbCr"
 
Back
Top