[英]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);
您可以使用
txtBox1.Text.Split(Environment.NewLine);
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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.