08.12.2011, 22:00
|
Прохожий
|
|
Регистрация: 08.12.2011
Сообщения: 7
Репутация: 10
|
|
Помогите с удалением слова в тексте!!
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
RichEdit1: TRichEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
FontDialog1: TFontDialog;
Button5: TButton;
Edit1: TEdit;
ColorDialog1: TColorDialog;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if opendialog1.execute then Richedit1.Lines.LoadFromFile(opendialog1.FileName);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if savedialog1.Execute then RichEdit1.lines.SaveToFile(savedialog1.FileName);
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if fontdialog1.Execute then
RichEdit1.SelAttributes.Assign(Fontdialog1.font);
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
if FontDialog1.Execute then
RichEdit1.SelAttributes.Color:=ColorDialog1.Color;
end;
procedure TForm1.Button5Click(Sender: TObject);
var
i,p:integer;
find:string;
begin
find:=edit1.text;
for i:=1 to RichEdit1.Lines.Count+1 do
if pos(find, RichEdit1.Lines.text)<>0
then
begin
RichEdit1.setfocus();
richedit1.SelStart:=pos(find,richedit1.Lines.Text)-1;
RichEdit1.sellength:=length(find);
end;
begin
while
pos(find,edit1.Text)<>0 do
richedit1.SelStart:=pos(find,richedit1.Lines.Text)-1;
RichEdit1.sellength:=delete(find,50,50);
delete(find,pos(find,edit1.Text),length(edit1.Text));
end;
end;
end.
Админ: Пользуемся тегами для оформления кода!
нужно составить поиск слова, которое задаю я, в тексте. Удалить все найдены слова !!
Последний раз редактировалось Admin, 08.12.2011 в 22:08.
|