Добрый день
подскажите пожалуйста как правильно обработать переменные TComponent
Прога типа таймера
Есть несколько TDateTimePicker на форме, выбираем в комбобоксе номер и в соответствующем Datetimepicker проверяем значение и при необходимости вносим изменение
Выскакивает access violation, пробовал делает create но не помогло. Не правильно как-то создаю видимо
Подскажите что не так
Код:
procedure TForm1.Button2Click(Sender: TObject);
var min2: integer;
DTPickE, DTPickS,Labelprice:tcomponent;
begin
DTPickS:=FindComponent('DTPickS'+Comb.Text);
DTPickE:=FindComponent('DTPickS'+Comb.Text);
LabelPrice:=FindComponent('LabelPrice'+Comb.Text);
if (DTPickS as Tdatetimepicker).Time=strtodatetime('00:00:00') then (DTPickS as Tdatetimepicker).Time:=Time
else
if (DTPickE as Tdatetimepicker).Time=strtodatetime('00:00:00') then
begin
(DTPickE as Tdatetimepicker).Time:=Time;
min2:=minutesbetween((DTPickS as Tdatetimepicker).Time,(DTPickE as Tdatetimepicker).Time);
if (min2 mod 60 > 30) then
(Labelprice as TLabel).Caption:=inttostr((min2 div 60)*150+150)
else (Labelprice as TLabel).Caption:=inttostr((min2 div 60)*150);
end
else
begin
(DTPickS as Tdatetimepicker).Time:=strtodatetime('00:00:00');
(DTPickE as Tdatetimepicker).Time:=strtodatetime('00:00:00');
(Labelprice as TLabel).Caption:='0';
end;
end;