Link to home
Start Free TrialLog in
Avatar of CodedK
CodedKFlag for Greece

asked on

Delete spaces in a Memo.

Hi.

How can i delete from each line in a Memo the begining spaces if there is any ?

For example:
---------------------------------------------------------
  Line 1                     <--- Line 1 (two spaces)
 Something               <--- Line 2 (one space)
Blabla                       <--- Line 3 (no spaces)
     Something else    <--- Line 4 (five spaces)
---------------------------------------------------------

Thanks in advance.
Avatar of ZhaawZ
ZhaawZ
Flag of Latvia image

var
  n : integer;
begin
for n := 0 to Memo1.Lines.Count - 1 do Memo1.Lines[n] := trim(Memo1.Lines[n]);
end;
Avatar of CodedK

ASKER

Hi ZhaawZ.
Thanks for your response..
Trim doesnt have any effect !
do you use trim() on *each* line or on whole txt?
Avatar of CodedK

ASKER

procedure TForm1.Button4Click(Sender: TObject);
var z:Integer;

begin
 For z:=Memo1.Lines.Count-1 downto 0   do
  Begin
    Trim(Memo1.Lines[z]);
  End;
end;
ASKER CERTIFIED SOLUTION
Avatar of ZhaawZ
ZhaawZ
Flag of Latvia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CodedK

ASKER

Oups...
Thank you very much :) :)
glad to help ;)
btw, I have had similar "problems" with other functions before (mainly with ReplaceString()) ;)