szymon1944 Posted November 10, 2013 Report Share Posted November 10, 2013 Witam, napisałem pewien program któremu użytkownik podaje ilość sekund a po ich upływie program się zamyka. Problem w tym że program nic nie odlicza i się nie zamyka.unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls;type TForm1 = class(TForm) Button1: TButton; Edit1: TEdit; Label1: TLabel; Timer1: TTimer; Label2: TLabel; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Label2Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);varb:integer;beginb:=strtoint(edit1.Text);label1.Caption:=inttostr(b+0);end;procedure TForm1.Timer1Timer(Sender: TObject);vara:integer;begina:=strtoint(label1.caption);label2.caption:='Zakonczenie programu za: '+ inttostr(a);a:=a-1;if a <= 0 then Application.Terminate;end;procedure TForm1.Button2Click(Sender: TObject);begintimer1.enabled:=true;end;procedure TForm1.Label2Click(Sender: TObject);beginend;end.Chodzi o to, że w pole edit1 wpisuje się ilość sekund, następnie klika w button1 i dane zostają wysłane do label1. Potem jest procedura timer-a i coś tu właśnie nie działa. Po kliknięciu w button2 timer powinien zacząć działać(enabled=false ustawiłem). W label2 wyświetla się "Zakończenie programu za: {podany czas np. 50}" Tu powinno być odliczanie ale nic się nie odlicza. Link to comment Share on other sites More sharing options...
nozyck Posted November 12, 2013 Report Share Posted November 12, 2013 1. Pusta linia między funkcjami - niby nic, a sprawi, że kod będzie czytelniejszy.2. Skąd timer ma "znać" te 50?3. Gdzie jest konwersja na ms? Link to comment Share on other sites More sharing options...