안녕하세요.
델파이세상(http://www.freechal.com/delphiworld)의 한상원입니다...^^
아주 초보적인 계산기입니다...^^;;;..너무 간단해서 설명이 필요없을거 같내요...
에고..부끄러워랑....^^;;
unit calculator;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TForm13 = class(TForm)
Memo1: TMemo;
Bevel1: TBevel;
Button12: TButton;
Bevel2: TBevel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Button8: TButton;
Button9: TButton;
Button10: TButton;
Button11: TButton;
Bevel3: TBevel;
Button13: TButton;
Button14: TButton;
Button15: TButton;
Button16: TButton;
Button17: TButton;
Button18: TButton;
Button19: TButton;
procedure Button17Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure Button11Click(Sender: TObject);
procedure Button14Click(Sender: TObject);
procedure Button15Click(Sender: TObject);
procedure Button16Click(Sender: TObject);
procedure Button10Click(Sender: TObject);
procedure Button12Click(Sender: TObject);
procedure Button13Click(Sender: TObject);
procedure Button18Click(Sender: TObject);
procedure Button19Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form13: TForm13;
sw, gu : integer;
result, sul : real;
implementation
{$R *.DFM}
procedure TForm13.Button17Click(Sender: TObject);
begin
sul := strtofloat(memo1.Lines[0]);
if result=0 then
result:=1;
case gu of
0 : result := sul;
1 : result := result+sul;
2 : result := result-sul;
3 : result := result*sul;
4 : result := result/sul;
end;
memo1.Lines[0]:='';
gu:=4;
sw:=0;
end;
procedure TForm13.Button1Click(Sender: TObject);
begin
if memo1.Lines[0]='0' then
memo1.Lines[0]:='';
memo1.Lines[0]:=memo1.Lines[0]+'1';
sw:=0;
end;
procedure TForm13.Button2Click(Sender: TObject);
begin
if memo1.Lines[0]='0' then
memo1.Lines[0]:='';
memo1.Lines[0]:=memo1.Lines[0]+'2';
sw:=0;
end;
procedure TForm13.Button3Click(Sender: TObject);
begin
if memo1.Lines[0]='0' then
memo1.Lines[0]:='';
memo1.Lines[0]:=memo1.Lines[0]+'3';
sw:=0;
end;
procedure TForm13.Button4Click(Sender: TObject);
begin
if memo1.Lines[0]='0' then
memo1.Lines[0]:='';
memo1.Lines[0]:=memo1.Lines[0]+'4';
sw:=0;
end;
procedure TForm13.Button5Click(Sender: TObject);
begin
if memo1.Lines[0]='0' then
memo1.Lines[0]:='';
memo1.Lines[0]:=memo1.Lines[0]+'5';
sw:=0;
end;
procedure TForm13.Button6Click(Sender: TObject);
begin
if memo1.Lines[0]='0' then
memo1.Lines[0]:='';
memo1.Lines[0]:=memo1.Lines[0]+'6';
sw:=0;
end;
procedure TForm13.Button7Click(Sender: TObject);
begin
if memo1.Lines[0]='0' then
memo1.Lines[0]:='';
memo1.Lines[0]:=memo1.Lines[0]+'7';
sw:=0;
end;
procedure TForm13.Button8Click(Sender: TObject);
begin
if memo1.Lines[0]='0' then
memo1.Lines[0]:='';
memo1.Lines[0]:=memo1.Lines[0]+'8';
sw:=0;
end;
procedure TForm13.Button9Click(Sender: TObject);
begin
if memo1.Lines[0]='0' then
memo1.Lines[0]:='';
memo1.Lines[0]:=memo1.Lines[0]+'9';
sw:=0;
end;
procedure TForm13.Button11Click(Sender: TObject);
begin
if memo1.Lines[0]='0' then
memo1.Lines[0]:='';
memo1.Lines[0]:=memo1.Lines[0]+'0';
sw:=0;
end;
procedure TForm13.Button14Click(Sender: TObject);
begin
sul := strtofloat(memo1.Lines[0]);
if result=0 then
result:=0;
case gu of
0 : result := sul;
1 : result := result+sul;
2 : result := result-sul;
3 : result := result*sul;
4 : result := result/sul;
end;
memo1.Lines[0]:='';
gu:=1;
sw:=0;
end;
procedure TForm13.Button15Click(Sender: TObject);
begin
sul := strtofloat(memo1.Lines[0]);
if result=0 then
result:=0;
case gu of
0 : result := sul;
1 : result := result+sul;
2 : result := result-sul;
3 : result := result*sul;
4 : result := result/sul;
end;
memo1.Lines[0]:='';
gu:=2;
sw:=0;
end;
procedure TForm13.Button16Click(Sender: TObject);
begin
sul := strtofloat(memo1.Lines[0]);
if result=0 then
result:=1;
case gu of
0 : result := sul;
1 : result := result+sul;
2 : result := result-sul;
3 : result := result*sul;
4 : result := result/sul;
end;
memo1.Lines[0]:='';
gu:=3;
sw:=0;
end;
procedure TForm13.Button10Click(Sender: TObject);
begin
memo1.Lines[0]:=memo1.Lines[0]+'.';
sw:=0;
end;
procedure TForm13.Button12Click(Sender: TObject);
begin
if sw=0 then
sul:=strtofloat(memo1.Lines[0]);
case gu of
0 : result := sul;
1 : result := result+sul;
2 : result := result-sul;
3 : result := result*sul;
4 : result := result/sul;
end;
memo1.Lines[0]:=format('%20.0f', [result]);
sw:=1;
end;
procedure TForm13.Button13Click(Sender: TObject);
begin
result:=0;
memo1.Lines[0]:='';
end;
procedure TForm13.Button18Click(Sender: TObject);
begin
close;
end;
procedure TForm13.Button19Click(Sender: TObject);
begin
if memo1.Lines[0]='0' then
memo1.Lines[0]:='';
memo1.Lines[0]:=memo1.Lines[0]+'00';
sw:=0;
end;
end.