Prevent line breaks in a TextArea

I encrypt the contents of “Labels” containing information and separate them with an
EndOfLine.
The encrypted result is displayed in a TextArea in a condensed form (without line breaks) but when I copy-paste (clipboard: Var c As Clipboard and TextArea2.Text = c.Text) the encrypted content in another TextArea of my application, it seems to execute line breaks? Why and how to prevent these line breaks and keep a condensed form?
Generate :


In my App :

Apply the same properties to the two TextArea.
In fact, duplicate the first TextArea, change the name opf the tatget TextArea in the Paste line and run…

This is not a problem of Copy / Paste (IMHO).

not the same. Is the clipboard the cause? very strange.

Maybe you have some clipboard tool, which translates the linefeeds from CR to CR+LF ?
As a workaround, you could filter the linefeeds before loading it into the textbox.

So how do I separate the information fields if I remove the line breaks? maybe using another separator? which neutral separator is generally used in this case?

Your required format has either chr(13) or chr(10) as a line separator.
Your pasted string has chr(13)+chr(10) after each line.

Just replace chr(13)+chr(10) with chr(13) in the complete string.
If that fails, replace chr(13)+chr(10) with chr(10).

So you do not remove the linebreaks. You convert the double line breaks into single ones.

Thanks I will try.

In the same computer / same running OS ?
Do you changed the TextArea Width ?
Do you changed the TextArea Font Nale ?
Do you pasted styled text with text that have a different Font Name ? Font Size ?
Even drag and drop can behave differently if the two TextArea are different (have different properties…).

NB: TextArea styles can be changed when you Paste (or drop) text with different properties (Font Name, Font Size, etc.) even if you set them in the IDE.

Enable the Horizontal Scrollbar :slight_smile:

2 Likes

You beat me to it. :slight_smile:

1 Like

You can take a look at the String.ReplaceLineEndings function.

Or do a .ReplaceLineEndings(EndOfLine....)

It’s not “or”, as we are both saying the same thing :wink:

Not really. Not every OS uses chr(13)+chr(10) as Native LineEnding and ReplaceLineEndings will replace all of them with the one given in the Parameter. Or? :slight_smile:

I was just suggesting the ReplaceLineEndings function, not the chr(13) or chr(10) bits.
You can pass any parameter you want, even ReplaceLineEndings(“A”); it’s up to the programmer to choose the correct one (EndOfLine being a good candidate).

Ah! Now i see MY issue. Forum was acting weird on my Machine. You are right. Thank you @Arnaud_N :slight_smile:

1 Like

How are you encrypting ? Encodebase64 ?