Solved

ASP.Net Count number of lines in a text box

Posted on 2013-12-31
2
673 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
  • 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

912 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now