![]() |
|
|
|||||||
| Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны |
![]() |
|
|
Опции темы | Поиск в этой теме | Опции просмотра |
|
#1
|
|||
|
|||
|
Код:
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. |
|
#2
|
|||
|
|||
|
у меня тока выделяет слова, помогите плиз!!!! Срочно нужно !!!
|
|
#3
|
||||
|
||||
|
Вот я за тебя твой же код "причесал". Может так виднее проблема будет:
Код:
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; |
|
#4
|
|||
|
|||
|
выбивает чтото такое
[Error] Unit1.pas(83): Incompatible types: 'Integer' and 'procedure, untyped pointer or untyped parameter' [Error] Unit1.pas (83): несовместимые типы: 'Integer' и 'процедуры, нетипизированный указатель или нетипизированный параметр' |
|
#5
|
||||
|
||||
|
Я не знаю, на что указывает 83 строка. Это твой код тебе виднее.
|
|
#6
|
|||
|
|||
|
Код:
Memo1.Lines.Text := StringReplace(Memo1.Lines.Text,A,'',[rfReplaceAll]); Не быстро, зато просто. А - строковая переменная, в которой находится искомое слово. |