473,387 Members | 1,611 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How can I trim a text pasted on a multiline textbox?

For example I pasted a text this text:

L1 line one blah blah blah blah
L2 another line 2 blah blah blah
L3 and another line three blah
L4 a last line blah blah blah


How can it be possible to trim it from a specified length up to the end of each line resulting the above example to be, say for example specifying a length of 3 and the result would be removing any extra white spaces beyond:

L1 lin
L2 ano
L3 and
L4 a <--- (no extra characters after 'a')

Please help, I'm just a beginner in programming, if you don't want to give the exact solution please provide me with helpful hints that I can study. Thanks!
Jul 11 '10 #1
2 2536
GaryTexmo
1,501 Expert 1GB
Your multiline string is actually a single string, but is broken up with newline characters. This will either be '\n' or sometimes '\n\r' (possibly '\r\n'). The Environment class has a newline property which contains this information. Still, it's best to visual inspect your string to see what the separator characters are.

Anyway, you can split your string using the String.Split method on the Environment.NewLine character. This will break your string up into lines. Then you can loop over each line in the resulting array and trim it to the desired length. You can then rebuild the merged string if you like.

MSDN has information on using the String.Split method. Please let me know how this turns out for you.
Jul 11 '10 #2
Thanks Gary, Yes I will surely let you know, but I think it would take me longer time before my next reply, I'm still going to figure out how it works and how I can apply it, I'm just self studying alone at home, so an easy help is not possible.. Thanks Gary! I'm going to read it on MSDN regarding the String.Split method.
Jul 12 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Michael C | last post by:
Hi all, I'm trying to add lines to a multiline textbox. Here's what I'd like to end up with in the textbox (as an example): Line1 Line2 Line3 I've tried a couple of methods but nothing...
7
by: Joel Finkel | last post by:
Folks, I have a form that has several TextBoxes, some of which have the TextMode set to MultiLine. Each is pre-loaded with data from a database. The user is allowed to modify each entry. The...
2
by: Enzo Marinelli | last post by:
Hello everyone I have a MultiLine TextBox, as follows <asp:TextBo Id="StreetAddress Rows="4 Runat="Server TextMode="MultiLine Width="100%"/
3
by: shachar | last post by:
hi all. i have a simple TextBox, Set MultiLine=True. how can i add a new line of text under the last line, so it would be a new line? thanks.
1
by: Flack | last post by:
Hey guys, I have two questions regarding the vertical srollbar of a multiline textbox. 1. I have an "Ok" button that is initially disabled. I want it to be enabled when the user scrolls the...
6
Coldfire
by: Coldfire | last post by:
I am having problems with Maxlength of Multiline "Textbox". I have browsed alot to find the solution. Tons of javascripts have been found but they all deal with <asp:textarea >............. and...
1
by: santosh2003 | last post by:
Hi All, How can we make autoscroll text in multiline textbox in asp.net? I have one textbox in home page i want to make the text in textbox auto scroll after load the page. Pls suggest how...
7
by: Anil Gupte | last post by:
I have read a lot about getting lines from a multiline textbox in VB.Net. However, I cannot for the life of me figure out how to write to a multiline textbox. Basically, I have created an array of...
2
by: Nathan Sokalski | last post by:
I have a multiline TextBox that I want to display the text used to create a control in an apsx file. I want each of these to be on a separate line in the TextBox. The only way I know of to place...
1
by: fniles | last post by:
I am using VB.NET 2008. I have a multiline textbox on the form that I would like to print when the user click on the "Print" button. With my codes below, when the text are in more than 1 page (say...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.