简体   繁体   中英

ASP.NET / VB.NET: Iterate through multiline textbox

I'm trying to iterate through each line of a multiline textbox. Something like:

For Each line In Me.txtBox1.Lines
    Response.Write line.Text
Next

Is there any neat way to do this, or will I need to write a character-by-character parser and look for carriage returns?

Thanks for any help,

Jason

For Each line As String In Me.txtBox1.Text.Split(vbLf)
    Response.Write(line)
Next
For Each line In Me.txtBox1.Text.Split({Environment.NewLine}, StringSplitOptions.None)
    Response.Write line
Next

Try

Response.Write (line & "<br />")    

You can use txtBox1.Text.Split(Environment.NewLine);

String.Split

In your case:

For Each line In Me.txtBox1.Text.Split(Environment.NewLine);
    Response.Write line.Text
Next

You don't need to do this char by char, just use split.

txtBox1.Text.Split(vbCrLf);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM