Calculadora em delphi
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;
type TForm1 = class(TForm) Display: TPanel; Bt7: TButton; Bt4: TButton; Bt1: TButton; Bt0: TButton; Bt8: TButton; Bt5: TButton; Bt2: TButton; BtInv: TButton; Bt9: TButton; Bt6: TButton; Bt3: TButton; BtPto: TButton; BtAdc: TButton; BtSub: TButton; BtDiv: TButton; BtMult: TButton; BtLimp: TButton; BtPercent: TButton; BtRaiz: TButton; BtIgual: TButton; procedure Bt0Click(Sender: TObject); procedure Bt1Click(Sender: TObject); procedure Bt2Click(Sender: TObject); procedure Bt3Click(Sender: TObject); procedure Bt4Click(Sender: TObject); procedure Bt5Click(Sender: TObject); procedure Bt6Click(Sender: TObject); procedure Bt7Click(Sender: TObject); procedure Bt8Click(Sender: TObject); procedure Bt9Click(Sender: TObject); procedure BtAdcClick(Sender: TObject); procedure BtSubClick(Sender: TObject); procedure BtDivClick(Sender: TObject); procedure BtMultClick(Sender: TObject); procedure BtIgualClick(Sender: TObject); procedure BtLimpClick(Sender: TObject); procedure BtRaizClick(Sender: TObject); procedure BtPercentClick(Sender: TObject); procedure BtInvClick(Sender: TObject); procedure BtPtoClick(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1; Valor: Real; //Guarda o valor informado a calculadora Operacao: Integer; //Guarda código da operação (1-4).
implementation
{$R *.dfm}
procedure TForm1.Bt0Click(Sender: TObject); begin Display.Caption := Display.Caption + '0'; end; procedure TForm1.Bt1Click(Sender: TObject); begin Display.Caption := Display.Caption + '1'; end; procedure TForm1.Bt2Click(Sender: TObject);