Re: calculator
- From: "prakash k" <prakash.kharvi.xsidesoft@xxxxxxxxx>
- Date: 26 Jun 2006 01:33:57 -0700
ya it is a good program but it only produces result of sequential
numbers.can u find program which actually displays buttons & screens
for which all operators can operations can be performed like +,_./ etc.
Andreas Koch wrote:
p.shakerifar@xxxxxxxxx wrote:
please say me how can I write a calculator program in delphi?
some thing that works like computers calculator
Minimalistic example:
Drop an TEdit and two Buttons on a Form.
Set the TEdits text to empty.
Give the first button the caption "1" and the
second one the caption "+".
Double click the form and both buttons to create event handlers.
----------------------------------------------------------------
Code:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private-Deklarationen }
number:extended;
displaying:boolean;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
number:=0;
displaying:=false;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if Displaying then
Edit1.text:='';
Edit1.text:=Edit1.text+'1';
Displaying:=False;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
number:=number+StrToFloat(Edit1.text);
Edit1.Text:=FloatToStr(Number);
Displaying:=True;
end;
end.
-----------------------------------------
This will create a calculator that allows you to add
sequences of "1"s.
You should be easily be able to add Input keys for other
numbers and operators from here.
.
- Follow-Ups:
- Re: calculator
- From: Maarten Wiltink
- Re: calculator
- References:
- calculator
- From: p . shakerifar
- Re: calculator
- From: Andreas Koch
- calculator
- Prev by Date: Re: Logical expressions help! (newbie)
- Next by Date: Re: calculator
- Previous by thread: Re: calculator
- Next by thread: Re: calculator
- Index(es):