--> Delete Space in Delphi Programming Text | Delphi Tips Trick

For Newbie

Saturday 24 September 2011

Delete Space in Delphi Programming Text

| Saturday 24 September 2011
            Basically, spacing character in a text can be erased by using trim order, but limited to the spacing character in the right or left side in a certain text. Besides, it can be used to erase the character in both right and left side in a text, but it can’t be used to erase the spacing character that is between the words or letters. To do that, it needs a function that have to be made first. Give name “DeleteSpaces” for the function, the source code is;

Function Deletespace(Str: string): string;
var
  i: Integer;
begin
  i:=0;
  while i<=Length(Str) do
 if Str[i]=' ' then Delete(Str, i, 1) // this is the main order to erase spacing character “”
    else Inc(i);
  Result:=Str;
end;

            The example of the implementation is as follows:

 



The source code type on Button Delete Space is :
procedure TForm1.Button1Click(Sender: TObject);
begin
  Edit2.Text:=DeleteSpace(Edit1.Text);
end;










I hope this article can give benefit to the visitors, readers, developer and me. Thanks for visiting and availability for sharing this article by pressing 
Share this on Facebook
or just press like button under this posting

Related Posts