Solved

ASP.Net Count number of lines in a text box

Posted on 2013-12-31
2
677 Views
Last Modified: 2014-01-15
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
0
Comment
Question by:brasso_42
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 26

Expert Comment

by:Shaun Kline
ID: 39748118
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
 
LVL 26

Accepted Solution

by:
Shaun Kline earned 500 total points
ID: 39748123
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question