Parse a long string into lines?

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.
 
B

Bryan Dickerson

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"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top