Delphi исходник калькулятора

admin

Administrator
Команда форума
5 янв 2013
202
105
43
#1
Простой исходник delphi калькулятора. Скриншот и полный код ниже, а также запакованный архив с программой + исходным кодом в аттаче.
C++:
unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, jpeg, ExtCtrls, StdCtrls, Math;
type
  TForm1 = class(TForm)
    ImgPozadi: TImage;
    Img1: TImage;
    Img2: TImage;
    Img3: TImage;
    Img4: TImage;
    Img5: TImage;
    Img6: TImage;
    Img7: TImage;
    Img8: TImage;
    Img9: TImage;
    Img0: TImage;
    ImgPlus: TImage;
    ImgRovnaSe: TImage;
    ImgMinus: TImage;
    LblVypocet: TLabel;
    LblVysledek: TLabel;
    ImgAllClean: TImage;
    ImgKrat: TImage;
    ImgDeleno: TImage;
    ImgCarka: TImage;
    ImgAns: TImage;
    ImgClean: TImage;
    ImgPi: TImage;
    ImgOff: TImage;
    ImgNaDruhou: TImage;
    ImgOdmocnina: TImage;
    ImgFaktorial: TImage;
    ImgSin: TImage;
    ImgCos: TImage;
    ImgTan: TImage;
    ImgNaTreti: TImage;
    Img2nd: TImage;
    ImgPZavorka: TImage;
    Label1: TLabel;
    procedure EnterNumber(number: string);
    procedure EnterZnamenko(znamenko: string);
    procedure Img1Click(Sender: TObject);
    procedure Img2Click(Sender: TObject);
    procedure Img3Click(Sender: TObject);
    procedure Img4Click(Sender: TObject);
    procedure Img5Click(Sender: TObject);
    procedure Img6Click(Sender: TObject);
    procedure Img7Click(Sender: TObject);
    procedure Img8Click(Sender: TObject);
    procedure Img9Click(Sender: TObject);
    procedure Img0Click(Sender: TObject);
    procedure ImgAllCleanClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure ImgMinusClick(Sender: TObject);
    procedure ImgRovnaSeClick(Sender: TObject);
    procedure ImgPlusClick(Sender: TObject);
    procedure ImgKratClick(Sender: TObject);
    procedure ImgDelenoClick(Sender: TObject);
    procedure ImgCarkaClick(Sender: TObject);
    procedure ImgAnsClick(Sender: TObject);
    procedure ImgCleanClick(Sender: TObject);
    procedure ImgOffClick(Sender: TObject);
    procedure ImgPiClick(Sender: TObject);
    procedure ImgNaDruhouClick(Sender: TObject);
    procedure ImgFaktorialClick(Sender: TObject);
    procedure ImgOdmocninaClick(Sender: TObject);
    procedure ImgPZavorkaClick(Sender: TObject);
    procedure Checking();
    procedure ImgSinClick(Sender: TObject);
    procedure ImgCosClick(Sender: TObject);
    procedure ImgTanClick(Sender: TObject);
    procedure Img2ndClick(Sender: TObject);
    procedure ImgNaTretiClick(Sender: TObject);


  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  ZeroNumber,ZnamenkoPressed,ImgRovnaSePressed,CisloPressed,Ochrana,carka,
  ImgAnsPressed,DruhaCast,moznost1,krat: boolean;
  PoloAns1,MeziAns,Ans, PomoAns{ImgAns},odmocnina,fce: real;
  Snumber: string;
  Operace,moznost: integer;


implementation

{$R *.dfm}

procedure TForm1.ImgOffClick(Sender: TObject);
begin
   Application.Terminate;
end;

procedure TForm1.Img0Click(Sender: TObject);
begin
 EnterNumber('0');
end;

procedure TForm1.Img1Click(Sender: TObject);
begin
 EnterNumber('1');
end;

procedure TForm1.Img2Click(Sender: TObject);
begin
 EnterNumber('2');
end;

procedure TForm1.Img2ndClick(Sender: TObject);
begin
 if DruhaCast=true then
 begin
 DruhaCast:=false;
 Label1.visible:=false;
 end
  else
  begin
 DruhaCast:=true;
 Label1.visible:=true;
  end;
end;

procedure TForm1.Img3Click(Sender: TObject);
begin
 EnterNumber('3');
end;

procedure TForm1.Img4Click(Sender: TObject);
begin
 EnterNumber('4');
end;

procedure TForm1.Img5Click(Sender: TObject);
begin
 EnterNumber('5');
end;

procedure TForm1.Img6Click(Sender: TObject);
begin
 EnterNumber('6');
end;

procedure TForm1.Img7Click(Sender: TObject);
begin
 EnterNumber('7');
end;

procedure TForm1.Img8Click(Sender: TObject);
begin
 EnterNumber('8');
end;

procedure TForm1.Img9Click(Sender: TObject);
begin
 EnterNumber('9');
end;

procedure TForm1.ImgPiClick(Sender: TObject);
begin
if moznost<>2 then begin

 if moznost=1 then
                begin
                 MeziAns:=MeziAns+(strtofloat(snumber)*PI);
                 Snumber:='0';
                 EnterNumber('3,14159265');

                 operace:=99 ;
                end
  else
 EnterNumber('3,14159265');

 moznost:=2;
 carka:=true;
 ZeroNumber:=true;
  DruhaCast:=false;
  Label1.visible:=false;
end;
end;

procedure TForm1.ImgAnsClick(Sender: TObject);
begin

  if moznost=4 then
                             begin
                              LblVypocet.caption:='0';
                              Snumber:='0';
                              PoloAns1:=0;
                              MeziAns:=0;
                              ZnamenkoPressed:=false;

                            end;
 if moznost=1 then
                begin
                 MeziAns:=MeziAns+(strtofloat(snumber)*strtofloat(LblVysledek.Caption));

                 Snumber:='0';
                 operace:=99 ;
                end
                else
                  Snumber:=LblVysledek.Caption;

 if (LblVypocet.Caption='0')or (LblVypocet.Caption='') or (LblVypocet.Caption='Nelze dмlit nulou!!!')
                           then LblVypocet.Caption:='Ans'
                             else LblVypocet.Caption:=LblVypocet.Caption+'Ans';

 ZeroNumber:=true;
if moznost<5 then moznost:=2;

 DruhaCast:=false;
 Label1.visible:=false;

end;
{operace:
 1-sинtбnн
 2-odинtбnн
 3-nбsobenн
 4-dмlenн
 100-nic}

procedure TForm1.ImgCleanClick(Sender: TObject);
begin
 Operace:=100;
 PoloAns1:=0;
 MeziAns:=0;
 LblVypocet.Caption:='';
 Snumber:='0';
 ZeroNumber:=false;
 PoloAns1:=0;
 carka:=false;
 ImgAnsPressed:=false;
 moznost:=0;
 DruhaCast:=false;
 Label1.visible:=false;
  moznost1:=true;
  fce:=1;
end;
...
1.png
 

Вложения