Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, XPMan;
- type
- TForm1 = class(TForm)
- Label1: TLabel;
- Edit1: TEdit;
- Button1: TButton;
- Button2: TButton;
- Button3: TButton;
- Button4: TButton;
- Button5: TButton;
- Button6: TButton;
- Button7: TButton;
- Button8: TButton;
- Button9: TButton;
- Button10: TButton;
- Button11: TButton;
- Button12: TButton;
- Button13: TButton;
- Button14: TButton;
- Button15: TButton;
- Button16: TButton;
- Button17: TButton;
- XPManifest1: TXPManifest;
- Button18: TButton;
- 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 Button10Click(Sender: TObject);
- procedure Button11Click(Sender: TObject);
- procedure Button14Click(Sender: TObject);
- procedure Button15Click(Sender: TObject);
- procedure Button12Click(Sender: TObject);
- procedure Button13Click(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure Button16Click(Sender: TObject);
- procedure Button17Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- number1, number2, total : real;
- operacao: integer;
- Pressionar_botao: boolean;
- implementation
- {$R *.dfm}
- procedure TForm1.Button1Click(Sender: TObject); //button 1
- begin
- Pressionar_botao:=true;
- Edit1.Text := Edit1.Text + (Sender as TButton).Caption
- end;
- procedure TForm1.Button2Click(Sender: TObject); //button two
- begin
- Pressionar_botao:=true;
- Edit1.Text := Edit1.Text + (Sender as TButton).Caption
- end;
- procedure TForm1.Button3Click(Sender: TObject); //button 3
- begin
- Pressionar_botao:=true;
- Edit1.Text := Edit1.Text + (Sender as TButton).Caption
- end;
- procedure TForm1.Button4Click(Sender: TObject); //button4
- begin
- Pressionar_botao:=true;
- Edit1.Text := Edit1.Text + (Sender as TButton).Caption
- end;
- procedure TForm1.Button5Click(Sender: TObject); //button 5
- begin
- Pressionar_botao:=true;
- Edit1.Text := Edit1.Text + (Sender as TButton).Caption
- end;
- procedure TForm1.Button6Click(Sender: TObject); //button 6
- begin
- Pressionar_botao:=true;
- Edit1.Text := Edit1.Text + (Sender as TButton).Caption
- end;
- procedure TForm1.Button7Click(Sender: TObject); //button 7
- begin
- Pressionar_botao:=true;
- Edit1.Text := Edit1.Text + (Sender as TButton).Caption
- end;
- procedure TForm1.Button8Click(Sender: TObject);//button 8
- begin
- Pressionar_botao:=true;
- Edit1.Text := Edit1.Text + (Sender as TButton).Caption
- end;
- procedure TForm1.Button9Click(Sender: TObject); //button 9
- begin
- Pressionar_botao:=true;
- Edit1.Text := Edit1.Text + (Sender as TButton).Caption
- end;
- procedure TForm1.Button10Click(Sender: TObject); //button 0
- begin
- Pressionar_botao:=true;
- Edit1.Text := Edit1.Text + (Sender as TButton).Caption
- end;
- //Operações
- procedure TForm1.Button11Click(Sender: TObject); //Mais
- begin
- operacao:=1;
- if Pressionar_botao=false then
- showmessage('Entre com um numero primeiro')
- else
- number1:=strToFloat(Edit1.Text);
- Edit1.Clear;
- end;
- procedure TForm1.Button12Click(Sender: TObject); //subtração
- begin
- operacao:=2;
- if Pressionar_botao=false then
- showmessage('Entre com um numero primeiro')
- else
- number1:=strToFloat(Edit1.Text);
- edit1.Clear;
- end;
- procedure TForm1.Button13Click(Sender: TObject);//multiplicação
- begin
- operacao:=3;
- if Pressionar_botao=false then
- showmessage('Entre com um numero primeiro')
- else
- number1:=strToFloat(Edit1.Text);
- edit1.Clear;
- end;
- procedure TForm1.Button14Click(Sender: TObject);//divisao
- begin
- operacao:=4;
- if Pressionar_botao=false then
- showmessage('Entre com um numero primeiro')
- else
- number1:=strToFloat(Edit1.Text);
- Edit1.Clear;
- end;
- //RESULTADO
- procedure TForm1.Button15Click(Sender: TObject);
- begin
- if Pressionar_botao=false then
- showmessage('Entre com um numero primeiro')
- else
- number2:=strtoFloat(Edit1.Text);
- case operacao of
- 1: total:=number1+number2;
- 2: total:=number1-number2;
- 3: total:=number1*number2;
- end ;
- if (number2=0) and (operacao=4) then
- showmessage('Não divida por zero')
- else
- case operacao of
- 4: total:=number1 / number2;
- end;
- edit1.Text:=FloatTostr(total);
- end;
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- //number1:=0;
- end;
- procedure TForm1.Button16Click(Sender: TObject); //Apagar
- begin
- Edit1.text:=' ';
- Pressionar_botao:=false;
- end;
- procedure TForm1.Button17Click(Sender: TObject); //virgula
- begin
- //Edit1.Text:=',';
- Edit1.Text := Edit1.Text + (Sender as TButton).Caption
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement