var flag:boolean; {$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);begin if not flag then begin button1.Caption:='运行'; flag:=true; end else begin button1.Caption:='停止'; flag:=false; end; end;
默认设为运行if btn1.caption='运行' then btn1.caption='停止' else if btn1.caption='停止' then btn1.caption='运行'
flag:boolean;
{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);begin
if not flag then
begin
button1.Caption:='运行';
flag:=true;
end
else
begin
button1.Caption:='停止';
flag:=false;
end;
end;
btn1.caption='停止'
else if btn1.caption='停止' then
btn1.caption='运行'