
10.02.2011, 19:56
|
Прохожий
|
|
Регистрация: 10.02.2011
Сообщения: 14
Репутация: 10
|
|
Помогите с задачей по Дельфи
Здравствуйте, помогите найти ошибку, я хочю создать программу, в которой индикатор прогресса заполся по мере того, как проходит время между первой и второй временной отметкой указанных в лейблах? Заполняются только два процента от силы. Помогите найти ошибку:
Код:
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls, ExtCtrls;
type
TForm2 = class(TForm)
Label1: TLabel;
Label2: TLabel;
ProgressBar1: TProgressBar;
Button1: TButton;
Timer1: TTimer;
procedure FormShow(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
Raz,Per:integer;
implementatiоn
{$R *.dfm}
procedure TForm2.FormShow(Sender: TObject);
var
Time1, Time2: TDateTime;
begin
Time1:=StrtoTime(Label1.Caption);
Time2:=StrtoTime(Label2.Caption);
Raz:=((StrToInt(FormatDateTime('h',Time2)))*60+StrToInt(FormatDateTime('n',Time2)))*60-
((StrToInt(FormatDateTime('h',Time1)))*60+StrToInt(FormatDateTime('n',Time1)))*60;
if Raz Mod 2 <> 0 then Raz:=Raz-1;
Per:=Raz div 100;
if StrToTime(Label1.Caption+':00') <= Time then Timer1.Enabled:=True;
end;
procedure TForm2.Timer1Timer(Sender: TObject);
begin
Timer1.Interval:=Timer1.Interval*Per;
progressbar1.Positiоn := progressbar1.Positiоn + 1;
if progressbar1.Positiоn = 100 then timer1.Enabled := false;
end;
end.
Админ: Пользуемся тегами!
|