Solved

Delete "White Spaces" in TMemo

Posted on 2004-09-08
3
400 Views
Last Modified: 2010-04-16
Hello All;

   I need to "Delete White Spaces"

I need all White Spaces in a TMemo to be deleted.

Example:
( Memo Outline )

-------------TOP----------------


above is "3" White Spaces
Below is "3" White Spaces



------------Bottom--------------

I need to have this located under a Button.

Any idea's on this will be great.

carrzkiss
0
Comment
Question by:Wayne Barron
3 Comments
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12007189
To remove spaces:
Memo1.Lines.Text := StringReplace(Memo1.Lines.Text, #32, '', [rfReplaceAll]);

To remove empty lines:
Memo1.Lines.Text := StringReplace(Memo1.Lines.Text, #13#10#13#10, #13#10, [rfReplaceAll]);
0
 
LVL 14

Accepted Solution

by:
Pierre Cornelius earned 20 total points
ID: 12007896
Alex, your method won't work. e.g. if you have 2 blank lines, it will only delete the first line. You would have to repeat that statement until there are no more #13#10#13#10 pairs found.

Here's another way:

procedure RemoveBlankLines(var m: TMemo);
var i: integer;
begin
  i:= 0;
  while i < m.Lines.Count do
  begin
    if m.Lines[i] = '' then m.Lines.Delete(i) else i:= i+1;
  end;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
  RemoveBlankLines(Memo1);
end;

Regards
Pierre
0
 
LVL 30

Author Comment

by:Wayne Barron
ID: 12008512
Thank you [Pierre];

  Your code works very well.

Thank You for your time again, in this post.
I awarded you the points because your code works well.
Even though with the last question that I asked, that you both
Were a part of, this code here does it all.

for Q :=Memo1.Lines.Count -1 downto 0 do
 begin
  if pos( 'http://', lowercase(Memo1.Lines[Q]) ) = 0
   then Memo1.Lines.Delete(Q);
 end;

http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_21123097.html

From Everst

Thank you all

Wayne
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now