unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Memo2: TMemo;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
SrsList,DestList1,DestList2: TStringList;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
SrsList:=TStringList.Create;
SrsList.Add('a');
SrsList.Add('b');
SrsList.Add('*');
SrsList.Add('c');
SrsList.Add('d');
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
SrsList.Free;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
i, j: Integer;
begin
DestList1:=Tstringlist.Create;
DestList2:=TStringlist.Create;
try
i:=SrsList.IndexOf('*');
for j:=0 to i-1 do
DestList1.Add(SrsList.Strings[j]);
for j:=i+1 to SrsList.Count-1 do
DestList2.Add(SrsList.Strings[j]);
Memo1.Lines.AddStrings(DestList1);
Memo2.Lines.AddStrings(DestList2);
finally
DestList1.Free;
DestList2.Free;
end;
end;
end.
温馨提示:答案为网友推荐,仅供参考