parsing multiline textbox

A

arby

I need to split a multiline textbox into separate lines. I tried parsing it using instr(vbcrlf,textbox1.text) in a loop to locate the end of each line but no success

Does anyone have a solution?
 
R

Rocky Moore

Have you tried the string "Split" method? It will build an array of all
lines.

--
Rocky Moore
www.RJSoft.com
www.HintsAndTips.com - Share your tips with the world!
~~~~~~~~~ Developer Tips Welcome! ~~~~~~~~~

arby said:
I need to split a multiline textbox into separate lines. I tried parsing
it using instr(vbcrlf,textbox1.text) in a loop to locate the end of each
line but no success.
 
J

Jos

arby said:
I need to split a multiline textbox into separate lines. I tried
parsing it using instr(vbcrlf,textbox1.text) in a loop to locate the
end of each line but no success.

Does anyone have a solution?

You swapped the arguments for Instr.
Use:
InStr(textbox1.text, vbcrlf)

Anyway, Rocky's solution is better.
 
A

arby

Thanks! The string.split method works great. I ended up using something like

strAnswers = Replace(txtAnswers.Text, vbLf, "").Split(vbCr

Since each line is actually split by 2 characters, 1 LF and 1 CR, this code snipet gives you very clean results (ie. no embedded LFs or empty array elements)
 

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

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top