Kalkulačka delphi
Níže je uveden pouze náhled materiálu. Kliknutím na tlačítko 'Stáhnout soubor' stáhnete kompletní formátovaný materiál ve formátu DOC.
Kalkulačka = DELPHI
unit Unit1;
public
minX,cisl, pam:real;
minOP:char;
smazat:boolean;
i:integer;
{ Public declarations }
end;
procedure TForm1.Cislice(Sender: TObject);
begin
if smazat then label1.caption:='';
if (Sender As TButton).CAption=',' then Button20.Enabled:=false;
label1.caption:=label1.caption+(Sender As TButton).Caption;
smazat:=false;
end;
procedure TForm1.operace(Sender: TObject);
begin
Button20.Enabled:=true;
cisl := StrToFloat(Label1.Caption );
ListBox1.Items.Add( FloatToStr( cisl ) );
try
case minOP of
'+': cisl := minX + cisl;
'-': cisl := minX - cisl;
'*': cisl := minX * cisl;
'/': cisl := minX / cisl;
end;
except
cisl := minx;
Label1.Caption := FloatTostr( cisl );
ListBox1.Items.Add( 'CHYBA' );
ShowMessage( 'CHYBA' );
end;
if minOP in ['+','-','*','/'] then
{ provadela se minula operace: }
begin
ListBox1.Items.Add( '=' );
ListBox1.Items.Add( FloatToStr( cisl ) )
end;
Label1.Caption := FloatTostr( cisl );
minX := cisl;
minOP := (Sender as TButton).Caption[1];
if minOP in ['+','-','*','/'] then
{ bude zase operace: }
ListBox1.Items.Add( minOp );
Smazat := TRUE
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
smazat:=true;
minOP:='C';
cisl:=0;
i:=0;
end;
procedure TForm1.Button22Click(Sender: TObject);
begin
ListBox1.Items.Clear();
end;
procedure TForm1.Button15Click(Sender: TObject);
begin
cisl:=0;
Label1.Caption:='0';
smazat:=true;
end;
procedure TForm1.Button16Click(Sender: TObject);
begin
Label2.Visible:=true;
pam:=StrToFloat(Label1.caption);
Button17.Enabled:=true;
Button21.Enabled:=true;
end;
procedure TForm1.Button17Click(Sender: TObject);
begin
Label1.Caption:=FloatToStr(pam);
end;
procedure TForm1.Button21Click(Sender: TObject);
begin
Label2.Visible:=false;
pam:=0;
Button17.Enabled:=false;
Button21.Enabled:=false;
end;
end.