ASP.Net Count number of lines in a text box

Hi

I have a text box which displays the results of a ping.  I only want to display the last 10 results in the textbox though.

How can I count the number of lines in the text box and if there is more than 9 delete the top line using VB.

Many thanks
LVL 1
brasso_42Asked:
Who is Participating?
 
Shaun KlineConnect With a Mentor Lead Software EngineerCommented:
You could also do this by splitting the text into an Array using the string.split method and then rejoining the array using the Array.Join method, including only those consecutive elements you want in the final string.
0
 
Shaun KlineLead Software EngineerCommented:
The ping lines should have a line termination/new line character which you should be able to use along with the String.Substring and String.IndexOf methods. It would look something like:

<textbox value>.substring(<textbox value>.indexOf(Environment.NewLine)+2)

Open in new window


The +2 will "move" the cursor past the two characters that make up the NewLine/Line Feed characters.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.