Hi,
My RichTextBox has multiple lines of text. Most of the lines unfortunately
end with a space.
Is it possible to replace the space and NewLine/Line Feed with just the
NewLine/LineFeed?
So in essence just removing the trailing space from each line?
Thanks,
Paul 3 5815
You might try the below code (not tested)
Dim str As String = ""
Dim i As Integer
' Loop through the characters in the text box
For i = 1 To RichTextBox1.Te xtLength
' Check the ascii values of the current character
' Note, an ascii value of 10 indicates enter
If Asc(Mid(RichTex tBox1.Text, i, 1)) = 10 Then
' trim the string to remove trailing spaces
str = Trim(str) & vbCrLf
Else
str += Mid(RichTextBox 1.Text, i, 1)
End If
Next i
RichTextBox1.Te xt = str
Thanks,
Seth
Paul wrote:
Hi,
My RichTextBox has multiple lines of text. Most of the lines unfortunately
end with a space.
Is it possible to replace the space and NewLine/Line Feed with just the
NewLine/LineFeed?
So in essence just removing the trailing space from each line?
Thanks,
Paul
Dim str As String 'Your string
Dim arr() As String = str.Split(New Char() {ControlChars.C rLf})
For i As Integer = 0 To arr.Length - 1
arr(i) = arr(i).TrimEnd( " ")
Next
str = String.Join(Con trolChars.CrLf, arr)
There might be a better way than this ...
Hi,
My RichTextBox has multiple lines of text. Most of the lines
unfortunately end with a space.
Is it possible to replace the space and NewLine/Line Feed with just
the
NewLine/LineFeed?
So in essence just removing the trailing space from each line?
Thanks,
Paul
Or try this...
str = Regex.Replace(s tr, "(\s)+\r\n" , ControlChars.Cr Lf)
Dim str As String 'Your string
Dim arr() As String = str.Split(New Char()
{ControlChars.C rLf})
For i As Integer = 0 To arr.Length - 1
arr(i) = arr(i).TrimEnd( " ")
Next
str = String.Join(Con trolChars.CrLf, arr)
There might be a better way than this ...
>Hi,
My RichTextBox has multiple lines of text. Most of the lines unfortunatel y end with a space.
Is it possible to replace the space and NewLine/Line Feed with just the NewLine/LineFeed? So in essence just removing the trailing space from each line? Thanks, Paul
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: aa |
last post by:
Anybody know the solution to trailing space in argument of
Runtime.getRuntime().exec(arg),
Process p = Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler
C:\\Documents and Settings\\XX\\Desktop\\- Copy of TestingFolder -\\jjjj
hihi.doc");
where there is 2 space between dash and "Copy of TestingFolder", but after
going through Runtime.getRuntime().exec(arg), it chopes off one space and
|
by: Donald Canton |
last post by:
What's the best way to remove trailing whitespace from a string? For
example: "John C. Doe \t" would become "John C. Doe". Thanks.
|
by: Andy B |
last post by:
I've tried using Trim or RTrim to strip trailing space characters from
my data. When I check on the transformed data space characters are
still there.
We have an address table containing two fields: BuildName and
RoadName. Both have the following properties: size 50, not indexed,
not required, allowed zero length. Some records have BuildName,
RoadName as null, some have content. No content is 50 chr long. When i
run a Len(BuildName)...
|
by: Mark Urish |
last post by:
I want to center-align the text in 2 Label controls, and I want the 1st char of their text to line up
------------------------------------------------------------------------------
label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
label1.Text = "IDLE"; //4 char strin
label2.Text = "RUN ";//4 char string,
//but trailing space ignored and it is centered as thoug...
|
by: Aaron |
last post by:
is there a way to remove all white spaces in the html output? ie. everything
as one line.
| |
by: Konstantinos Pachopoulos |
last post by:
Hi,
is there something corresponding to the java String.trim() method, ie
trim start and trailing space/tab chars from string?
say convert " asdf " to "asdf"?
Thnx
|
by: =?Utf-8?B?R2Vvcmdl?= |
last post by:
Hello everyone,
I think in built-in C/C++ functions, there is no direct function call to
trim heading and trailing space characters, right? So, we have to implement
it manually by iterating the string to check character one by one.
Support not using MFC.
|
by: lihao0129 |
last post by:
Hi, folks:
I recently went through a strange problem with my Javascript code,
say: I have a string variable which are from a 'textarea' element and
I want to remove the trailing newlines inside the string. I am using
something like the following:
var txt = textarea_element.value.replace(/\n*$/, '');
But this replaced only the last newline(by changing '' to 'K', and
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |