高分再提问.....如何提高效率!!~~!~!急!~急!~急@!!~~!
procedure TRichEdit2.SetInputText(const Value: string);
var WS1, WS2: string;
i, L, P, Count: Integer;
begin
FInputText := Value;
Self.SelStart := 0;
Self.SelLength := Length(Self.Text);
Self.SelAttributes.Color:=Font.Color;
WS1 := Value; // StringToOleStr(Value);
WS2 := Self.Text; //StringToOleStr(Self.Text);
L := Length(WS2);
if Length(WS1)<=0 then Exit;
Count := 0;
P := 0;
for i := 1 to L do
begin
if ws1[i] = ws2[i] then
inc(Count)
else
begin
if (Count mod 2)=1 then
begin
if Pos(ws2[i],Checkstr)<=0 then
dec(Count);
end;
Self.SelStart := P;
Self.SelLength := Count;
Self.SelAttributes.Color := clRed;
P := i;
Count := 0;
end;
if (i>Length(ws1)) then
begin
Count:=0;
end;
end;
if Count <> 0 then
begin
Self.SelStart := P;
Self.SelLength := Count;
Self.SelAttributes.Color := clRed;
end;
end;
//我要写一个考试打字 的程序,上面的这段代码是把录入文本和要求的文本进行对比,如果正确,那么字就变成红色,否则不变色....程序执行都没问题了,但是现在的效率很地下,如果给定文本再400字以上,打字速度和颜色显示的速度就很慢....如何提高这个效率呢?程序里是再Memo1里的Onchange事件里把来判断打的字是否正确的,Value实际上就是Memo1.Lines.Text..但是每次都要去Memo1.Text作为字符串好像效率太低了..如何提高..求各位高人指点...拜托..分不够再加