unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 =
class(TForm)
bt0: TButton;
bt9: TButton;
bt8: TButton;
bt7: TButton;
bt6: TButton;
bt5: TButton;
bt4: TButton;
bt3: TButton;
bt2: TButton;
bt1: TButton;
btPunkt: TButton;
bt00: TButton;
Edit1: TEdit;
Panel1: TPanel;
btPlus: TButton;
btMal: TButton;
btGeteilt: TButton;
btMinus: TButton;
btGleich: TButton;
btClear: TButton;
Label1: TLabel;
btMplus: TButton;
btMminus: TButton;
btMR: TButton;
btMC: TButton;
procedure ZeiButtonClick(Sender: TObject);
procedure opButtonClick(Sender: TObject);
procedure btClearClick(Sender: TObject);
procedure btGleichlik(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var strBuff1, strBuff2:
string;
op: Char;
var mode: Byte = 1;
procedure TForm1.btClearClick(Sender: TObject);
begin
if mode = 1
then StrBuff1 := '
'
else StrBuff2 := '
';
edit1.text := '
'
end;
procedure TForm1.ZeiButtonClick(Sender: TObject);
var zei: Char;
begin
if Sender = bt0
then zei := '
0';
if Sender = bt1
then zei := '
1';
if Sender = bt2
then zei := '
2';
if Sender = bt3
then zei := '
3';
if Sender = bt4
then zei := '
4';
if Sender = bt5
then zei := '
5';
if Sender = bt6
then zei := '
6';
if Sender = bt7
then zei := '
7';
if Sender = bt8
then zei := '
8';
if Sender = bt9
then zei := '
9';
if Sender = btPunkt
then zei := '
.';
if mode = 1
then
begin
strBuff1 := strBuff1 + zei;
edit1.text := strBuff1
end else
begin
strBuff2 := strBuff2 + zei;
edit1.text := strBuff2
end;
end;
procedure TForm1.opButtonClick(Sender: TObject);
begin
if mode = 1
then
begin
if Sender = btPlus
then op := '
+';
if Sender = btMinus
then op := '
-';
if Sender = btGeteilt
then op := '
/';
if Sender = btMal
then op := '
*';
StrBuff2 := '
';
mode := 2
end
end;
procedure TForm1.btGleichlik(Sender: TObject);
var res, op1, op2: Double;
code: Integer;
s:
string;
begin
if mode = 2
then begin
Val(strBuff1, op1, code);
Val(strBuff2, op2, code);
case op
of
'
+': res := op1 + op2;
'
-': res := op1 - op2;
'
/': res := op1 / op2;
'
*': res := op1 * op2;
end;
s:= Format ('
%g', [res]);
edit1.text := s;
mode := 1;
strBuff1 := '
'
end
end;
end.