DelphiFan Magazine

Top Menu

Main Menu

  • DELPHI
  • CODE SAMPLES
  • FIREMONKEY
  • DATABASE
  • RELEASES
  • VIDEOS
  • REVIEW
  • TECH NEWS

logo

DelphiFan Magazine

  • DELPHI
  • CODE SAMPLES
  • FIREMONKEY
  • DATABASE
  • RELEASES
  • VIDEOS
  • REVIEW
  • TECH NEWS
  • How to add a server application written in UNIGUI to startup?

  • UniGUI Expiry Link Anonymizer

  • UniGUI Add CAPTCHA to the WEB project

  • UniGui. Unique hybrid of Delphi and JS

  • How to transform a blob field into string lines (varchar) in SQL Firebird?

CODE SAMPLESDELPHI
Home›CODE SAMPLES›How to Remove Blank Lines from Memo?

How to Remove Blank Lines from Memo?

By admin
January 3, 2021
491
0
Share:

The other day I had a TMemo in my application where the user reported some observation of the product.
So, in some cases, I started to have a printing problem because the field was taking up too much space.

After checking, I noticed how many times the user was putting several blank lines at the end of TMemo without realizing it, so I thought of an automatic way to remove these blank lines at the end of the field.

Well, initially I came up with a code like this:

procedure TForm1.Button1Click(Sender: TObject);
var
 i: integer;
begin
 for i := Memo1.Lines.Count/1 downto 0 do
   if trim(Memo1.Lines[i]) = '' then
      Memo1.Lines.Delete(i);
end;

Okay, it works, but what if you need it for RichEdit or other types of lists?

Improving the Code!
Let’s create a procedure to be able to use this feature in several places!

procedure RemoverwhiteLines(aList : TStrings);
var
 i: integer;
begin
 for i := aList .Count downto 0 do
   if (Trim(aList [i]) = '') then
   begin
     aList.Delete(i);
   end;
end;

Now for an example of use with the procedure.

// Example with memo
procedure TForm1.Button1Click(Sender: TObject);
begin
  RemoverwhiteLines(Memo1.Lines);
end;
 
// Example with RichEdit
procedure TForm1.Button1Click(Sender: TObject);
begin
  RemoverwhiteLines(RichEdit1.Lines);
end;

I hope I can help.

Regards and see you next post.

 
 
Tagsdelphidelphi memomemomemo linesremove blank linesremove lines
Previous Article

Where to download OpenSSL binaries?

Next Article

How to put a DateTimePicker in the ...

0
Shares
  • 0
  • +
  • 0
  • 0
  • 0
  • 0

admin

Related articles More from author

  • DELPHIVIDEOS

    Setup and deploy of first iOS App with Delphi

    September 27, 2020
    By admin
  • CODE SAMPLESDELPHI

    How to add a server application written in UNIGUI to startup?

    January 27, 2021
    By admin
  • DELPHI

    New Attributes in Delphi

    October 4, 2020
    By admin
  • CODE SAMPLESDELPHI

    Internationalizing your application in Delphi

    January 7, 2021
    By admin
  • CODE SAMPLESDELPHIFIREMONKEY

    Delphi Android internal system related operations

    December 11, 2020
    By admin
  • CODE SAMPLESDELPHI

    UniGUI Expiry Link Anonymizer

    January 27, 2021
    By admin

Leave a reply Cancel reply

You may interested

  • CODE SAMPLESDELPHI

    How to extract text between HTML or XML tags?

  • CODE SAMPLESDELPHI

    Use of Unigui fontawesome icon font library

  • CODE SAMPLESDELPHI

    Rapidly Use Delphi FireDAC In A Multithreaded Environment With The FireDAC.Pooling Sample

  • LATEST REVIEWS

  • TOP REVIEWS

Timeline

  • January 27, 2021

    How to add a server application written in UNIGUI to startup?

  • January 27, 2021

    UniGUI Expiry Link Anonymizer

  • January 26, 2021

    UniGUI Add CAPTCHA to the WEB project

  • January 26, 2021

    UniGui. Unique hybrid of Delphi and JS

  • January 13, 2021

    How to transform a blob field into string lines (varchar) in SQL Firebird?

Latest Comments

Find us on Facebook

Follow Us on Instagram

logo

Our website, law, laws, copyright and aims to be respectful of individual rights. Our site, as defined in the law of 5651 serves as a provider of space. According to the law, contrary to the law of site management has no obligation to monitor content. Therefore, our site has adopted the principle of fit and remove. Works are subject to copyright laws and is shared in a manner that violated their legal rights, or professional associations, rights holders who, adsdelphi@gmail.com I can reach us at e-mail address. Complaints considered to be infringing on the examination of the content will be removed from our site.

About us

  • 660 Pennsylvania Avenue Southeast #100 Washington, DC 20003
  • 0123456789
  • adsdelphi@gmail.com
  • Recent

  • Popular

  • Comments

  • How to add a server application written in UNIGUI to startup?

    By admin
    January 27, 2021
  • UniGUI Expiry Link Anonymizer

    By admin
    January 27, 2021
  • UniGUI Add CAPTCHA to the WEB project

    By admin
    January 26, 2021
  • UniGui. Unique hybrid of Delphi and JS

    By admin
    January 26, 2021
  • How to add a server application written in UNIGUI to startup?

    By admin
    January 27, 2021
  • Amazing Cross Platform Email App Sample In Delphi 10.4.1 FireMonkey For Android And IOS

    By admin
    August 13, 2020
  • Critical Update Available For Delphi FireMonkey 10.4.1 On Android, IOS, OSX, Windows, And Linux

    By admin
    September 4, 2020
  • Setting up the IDE for your first Android Application in Delphi

    By admin
    September 7, 2020

Follow us

Find us on Facebook

© Copyright Delphifan Forum. All rights reserved.