一个进度条,走完后,间隔2秒后,自动关闭程序,有一个timer2控件,我想在进度条显示“完成”的时候,触发timer2:procedure TForm1.Timer2Timer(Sender: TObject);
begin
if label1.Caption:='完成!' then
close;
end;
end;
end.显示错误,[Error] Unit1.pas(59): Type of expression must be BOOLEAN
[Error] Unit1.pas(62): '.' expected but ';' found
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'怎么回事?~~我设置一个变量,然后累加剩余的秒数,完成后触发timer2行么??~~~谁有好的办法,其他的控件,说说,我现在只学到timer这里~~- -谢谢了~~
begin
if label1.Caption:='完成!' then
close;
end;
end;
end.显示错误,[Error] Unit1.pas(59): Type of expression must be BOOLEAN
[Error] Unit1.pas(62): '.' expected but ';' found
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'怎么回事?~~我设置一个变量,然后累加剩余的秒数,完成后触发timer2行么??~~~谁有好的办法,其他的控件,说说,我现在只学到timer这里~~- -谢谢了~~
begin
if label1.Caption='完成!' then
begin
Timer2.Enabled:=false;
close;
end;
end; end.
先timer2.Interval:=2000;
timer2.enabled:=false;
再if trackbar1.Position>=trackbar1.Max then
begin
animate1.Active:=false;
label1.caption:='完成!';
timer2.enabled:=true;最后procedure TForm1.Timer2Timer(Sender: TObject);
begin
if trackbar1.Position>=trackbar1.Max then
close;
end;
end.谁有更简洁的办法么~~~(楼上我会给你分的,怪我。。一着急忘了~~)
a:=3 就表示让a的值是3
if label1.caption = '完成!' then
才对,基本功底不扎实……
标示符错误
end;
end;
多了一个end;
你的两个报错是因为这两个原因
if trackbar1.Position>=trackbar1.Max then
begin
animate1.Active:=false;
label1.caption:='完成!';
sleep(2000);
close;
end;
begin
if label1.Caption='完成!' then
close;
end; end.
close只是关闭当前窗体。
begin
if trackbar1.Position>=trackbar1.Max then
close;
end;
end.
"
这里不需要判断 if trackbar1.Position>=trackbar1.Max 了
直接
begin
Application.Terminate;
end
就可以了,这样可以简洁一点