--> Delete Chararter in a Text in Delphi Programming | Delphi Tips Trick

For Newbie

Tuesday 27 September 2011

Delete Chararter in a Text in Delphi Programming

| Tuesday 27 September 2011
Delete Chararter in a Text in Delphi Programming
Sometimes it is needed erasing toward certain character from a text in component label or edit, or other components. For example, when a data in the form of “my father” will be erased * character that exist so that become “my fther”, in this case, can be made a function. Give name “DeleteString” to the function, the source code:  The example of the implementation is as follows: Source Code that is typed in delete string button is:

Function DeleteString(Str: string): string;
var
  i: Integer;
begin
  i:=0;
  while i<=Length(Str) do
 if Str[i]=' a' then Delete(Str, i, 1)// ini adalah perintah utama untuk menghapus karakter “a”
    else Inc(i);
  Result:=Str;
end;




The source code on Button1 On Click

procedure TForm1.Button1Click(Sender: TObject);
begin
  Edit2.Text:=DeleteString(Edit1.Text);
end;


  I hope this writing 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