Delphi Windows Calculator

0
(0)
2 289
Free
SKU-GD1E1Y2L2E3
PAS

This application is a source code file describing the use of Windows Calculator with a Delphi. Delphi Programming Language will be very useful in learning. In addition, Delphi mathematical operations to add, subtract, multiply and divide will give you an idea of how to do.

 

We are adding 16 buttons, 4 pieces of labels and 4 labels to our form which we have started with delphi as a starting point for calculating the logic and making a very simple calculator. We will use buttons to multiply, divide, add and subtract from these components.

 

The overview of our application will be as follows:

 

Our codes are:

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    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;
    procedure Button15Click(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 Button10Click(Sender: TObject);
    procedure Button11Click(Sender: TObject);
    procedure Button12Click(Sender: TObject);
    procedure Button13Click(Sender: TObject);
    procedure Button14Click(Sender: TObject);
    procedure Button16Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  a:Double;
  b:Double;
  c:Double;

implementation

{$R *.dfm}

procedure TForm1.Button10Click(Sender: TObject);
begin
  if Edit3.Text = '' then
    Edit1.Text:=Edit1.Text + '0'
    else
    begin
      Edit2.Text:=Edit2.Text + '0'
    end;
end;

procedure TForm1.Button11Click(Sender: TObject);
begin
  Edit3.Text:='+';
end;

procedure TForm1.Button12Click(Sender: TObject);
begin
  Edit3.Text:='-';
end;

procedure TForm1.Button13Click(Sender: TObject);
begin
  Edit3.Text:='x';
end;

procedure TForm1.Button14Click(Sender: TObject);
begin
  Edit3.Text:='/';
end;

procedure TForm1.Button15Click(Sender: TObject);
begin
Edit1.Text:='';
Edit2.Text:='';
Edit3.Text:='';
Edit4.Text:='';

end;

procedure TForm1.Button16Click(Sender: TObject);
begin
  if Edit3.Text ='+' then
    a:=StrToInt(Edit1.Text);
    b:=StrToInt(Edit2.Text);
    c:=a+b;
    Edit4.Text:=FloatToStr(c);

  if Edit3.Text ='-' then
    a:=StrToInt(Edit1.Text);
    b:=StrToInt(Edit2.Text);
    c:=a-b;
    Edit4.Text:=FloatToStr(c);

   if Edit3.Text ='*' then
    a:=StrToInt(Edit1.Text);
    b:=StrToInt(Edit2.Text);
    c:=a*b;
    Edit4.Text:=FloatToStr(c);

  if Edit3.Text ='/' then
    a:=StrToFloat(Edit1.Text);
    b:=StrToFloat(Edit2.Text);
    c:=(a)/(b);
    Edit4.Text:=FloatToStr(c)


end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if Edit3.Text = '' then
    Edit1.Text:=Edit1.Text + '1'
    else
    begin
      Edit2.Text:=Edit2.Text + '1'
    end;

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  if Edit3.Text = '' then
    Edit1.Text:=Edit1.Text + '2'
    else
    begin
      Edit2.Text:=Edit2.Text + '2'
    end;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  if Edit3.Text = '' then
    Edit1.Text:=Edit1.Text + '3'
    else
    begin
      Edit2.Text:=Edit2.Text + '3'
    end;
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
  if Edit3.Text = '' then
    Edit1.Text:=Edit1.Text + '4'
    else
    begin
      Edit2.Text:=Edit2.Text + '4'
    end;
end;

procedure TForm1.Button5Click(Sender: TObject);
begin
  if Edit3.Text = '' then
    Edit1.Text:=Edit1.Text + '5'
    else
    begin
      Edit2.Text:=Edit2.Text + '5'
    end;
end;

procedure TForm1.Button6Click(Sender: TObject);
begin
  if Edit3.Text = '' then
    Edit1.Text:=Edit1.Text + '6'
    else
    begin
      Edit2.Text:=Edit2.Text + '6'
    end;
end;

procedure TForm1.Button7Click(Sender: TObject);
begin
  if Edit3.Text = '' then
    Edit1.Text:=Edit1.Text + '7'
    else
    begin
      Edit2.Text:=Edit2.Text + '7'
    end;
end;

procedure TForm1.Button8Click(Sender: TObject);
begin
  if Edit3.Text = '' then
    Edit1.Text:=Edit1.Text + '8'
    else
    begin
      Edit2.Text:=Edit2.Text + '8'
    end;
end;

procedure TForm1.Button9Click(Sender: TObject);
begin
  if Edit3.Text = '' then
    Edit1.Text:=Edit1.Text + '9'
    else
    begin
      Edit2.Text:=Edit2.Text + '9'
    end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Form1.Text:='DELPHI CALCULATOR By: Teody';
  Form1.Position:=poMainFormCenter;
end;

end.

No reviews found.

No comments found for this product. Be the first to comment!

This site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies.

DMCA.com Protection Status Whatsapp Sipariş