Solved

ASP.Net Count number of lines in a text box

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

696 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