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?
Than开发者_C百科ks 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
You don't need to do this char by char, just use split.
txtBox1.Text.Split(vbCrLf);
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
Try
Response.Write (line & "<br />")
精彩评论