unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;
  i:Integer=1;
implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var TmpStr,Str:String;
    j:integer;
begin
  Str:='asdfs';
  TmpStr:=Copy(Memo1.Text,i,Length(Memo1.Text)-i);
  j:=pos(Str,TmpStr);
  if j<>0 then
  begin
    memo1.SelStart:=i+j-2;
    memo1.SelLength:=Length(Str);
    memo1.SetFocus;
    i:=i+j;
  end else
    showmessage('搜索完成');
end;end.