procedure TForm1.Button1Click(Sender: TObject);
begin
if opendialog1.Execute then
rich1.Lines.LoadFromFile(opendialog1.FileName );
label2.Caption := ExtractFilename(opendialog1.FileName) ;
rich2.Enabled :=false;
end;procedure TForm1.Rich2Change(Sender: TObject);
var
i:integer;
k:integer;
m:integer;
n:integer;
begink:=0;
for i:=1 to length(rich2.Text ) do
begin
if i<length(rich1.Text) then
begin
rich1.SelStart :=i-2;
rich1.SelLength :=1;
rich2.SelStart :=i-2;
rich2.SelLength :=1;
edit1.Text :=rich1.SelText ;
edit2.Text :=rich2.SelText ;
if rich1.SelText =rich2.SelText then
begin
rich2.SelAttributes.Color :=clgreen;
k:=k+1;
end
else
rich2.SelAttributes.Color :=clred
end
else
begin
showmessage('文章录入完成');
rich2.Enabled :=false;
timer1.Enabled :=false;
end;
label6.Caption :=inttostr(i div 2)+'字';
if f=0 then m:=0 else m:=trunc((i / f) * 60);
label4.Caption :=inttostr(m)+ '字/分';
if i=1 then n:=100 else n:=trunc(k / (i-1) * 100);
label8.Caption :=inttostr(n)+'%';
p:=i; end;
rich2.SelStart :=i;
rich2.SelLength :=0;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
Rich2.Enabled := True ;
Timer1.Enabled := True ;
end;procedure TForm1.Timer1Timer(Sender: TObject);
begin
f:=f+1;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
rich1.Visible :=false;
rich1.Text :='';
rich2.Text :='';
end;
begin
if opendialog1.Execute then
rich1.Lines.LoadFromFile(opendialog1.FileName );
label2.Caption := ExtractFilename(opendialog1.FileName) ;
rich2.Enabled :=false;
end;procedure TForm1.Rich2Change(Sender: TObject);
var
i:integer;
k:integer;
m:integer;
n:integer;
begink:=0;
for i:=1 to length(rich2.Text ) do
begin
if i<length(rich1.Text) then
begin
rich1.SelStart :=i-2;
rich1.SelLength :=1;
rich2.SelStart :=i-2;
rich2.SelLength :=1;
edit1.Text :=rich1.SelText ;
edit2.Text :=rich2.SelText ;
if rich1.SelText =rich2.SelText then
begin
rich2.SelAttributes.Color :=clgreen;
k:=k+1;
end
else
rich2.SelAttributes.Color :=clred
end
else
begin
showmessage('文章录入完成');
rich2.Enabled :=false;
timer1.Enabled :=false;
end;
label6.Caption :=inttostr(i div 2)+'字';
if f=0 then m:=0 else m:=trunc((i / f) * 60);
label4.Caption :=inttostr(m)+ '字/分';
if i=1 then n:=100 else n:=trunc(k / (i-1) * 100);
label8.Caption :=inttostr(n)+'%';
p:=i; end;
rich2.SelStart :=i;
rich2.SelLength :=0;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
Rich2.Enabled := True ;
Timer1.Enabled := True ;
end;procedure TForm1.Timer1Timer(Sender: TObject);
begin
f:=f+1;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
rich1.Visible :=false;
rich1.Text :='';
rich2.Text :='';
end;
解决方案 »
- 能不能将存入数据库中的二进制流文件保存到一变量读出?
- TidTcpClient接收数据的问题,请大家指点
- 如果应付电信局对路由器上网方式的限制?
- 请帮忙写一个入门级的看图程序。
- Delphi中如何向ORACLE中插入日期型字段值?
- 再次请教读取ini文件行的问题,谢谢
- 各位大叔大婶!fastreport里的frCSVExport控件怎么用啊?????我急急急!!!
- 请问高手怎么获取OE的邮件地址?
- 请教一个TQuery的问题,如何得到一个打开的空的数据集?
- 用delphi调用execl,如何打开一个已存在的execl文件?有分
- 上海金仕达卫宁软件有限公司怎么样啊?
- Chart 能否实现打印的预览
每一个 rich2.Text :=''; 操作都会触发 Rich2Change 事件 。你的程序在一开始 FormCreate 中就有一个该操作,岂不是很乱??