Информатика. Программирование в Delphi
173
procedure TForm1.EditKeyPress(Sender: TObject; var Key: Char);
var
Edit:TEdit;
begin
Edit:=Sender as TEdit;
case key of
'0'..'9',#8:;
',','.':
begin
key:=DecimalSeparator;
if pos(key,Edit.Text)<>0 then
key:=#0;
end;
'-':
if Edit.Tag=0 then
begin
if pos(key,Edit.Text)=0 then
Edit.Text:='-'+Edit.Text;
key:=#0;
end
else
key:=#0;
else
key:=#0;
end;
end;
procedure TForm1.EditChange(Sender: TObject);
begin
ListBox1.Items.Clear;
ListBox2.Items.Clear;
Button1.Enabled:=false;
if (Edit1.Text<>'') and (Edit1.Text<>'-') and
(Edit2.Text<>'') and (Edit2.Text<>'-') and
(Edit3.Text<>'') and (StrToFloat(Edit3.Text)<>0) then
if StrToFloat(Edit1.Text)>StrToFloat(Edit2.Text) then
begin
ListBox(ListBox1,StrToFloat(Edit1.Text),StrToFloat(Edit2.Text),
StrToFloat(Edit3.Text));
ListBox(ListBox2,StrToFloat(Edit1.Text),StrToFloat(Edit2.Text),
StrToFloat(Edit3.Text));
ListBox1.ItemIndex:=0;
ListBox2.ItemIndex:=ListBox2.Items.Count-1;
Button1.Enabled:=true;
end;
end;