آلــــة حاسبـــة
برمجة آلة حاسبة عادية والمراد من هذا هو تعلم بعض تقنيات
الحساب للمبتدئين في البرمجة
code
var
Form1: TForm1;
implementation
{$R *.DFM}
Var
Operation1: Real;
Operation2:string;
procedure TForm1.ButtonEffaceClick(Sender: TObject);
begin
Edit1.Text:='';
Edit1.SetFocus;
end;
procedure TForm1.Button0Click(Sender: TObject);
begin
Edit1.Text:=Edit1.Text+'0';
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit1.Text:=Edit1.Text+'1'
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Edit1.Text:=Edit1.Text+'2'
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Edit1.Text:=Edit1.Text+'3'
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
Edit1.Text:=Edit1.Text+'4'
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
Edit1.Text:=Edit1.Text+'5'
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
Edit1.Text:=Edit1.Text+'6'
end;
procedure TForm1.Button7Click(Sender: TObject);
begin
Edit1.Text:=Edit1.Text+'7';
end;
procedure TForm1.Button8Click(Sender: TObject);
begin
Edit1.Text:=Edit1.Text+'8'
end;
procedure TForm1.Button9Click(Sender: TObject);
begin
Edit1.Text:=Edit1.Text+'9'
end;
procedure TForm1.ButtonVirguleClick(Sender: TObject);
begin
Edit1.Text:=Edit1.Text+','
end;
procedure TForm1.ButtonPlusClick(Sender: TObject);
begin
Operation1:=StrToFloat(Edit1.Text);
Operation2:='+';
Edit1.Text:='';
end;
procedure TForm1.ButtonMoinsClick(Sender: TObject);
begin
Operation1:=StrToFloat(Edit1.Text);
Operation2:='-';
Edit1.Text:='';
end;
procedure TForm1.ButtonMultClick(Sender: TObject);
begin
Operation1:=StrToFloat(Edit1.Text);
Operation2:='x';
Edit1.Text:='';
end;
procedure TForm1.ButtonDivClick(Sender: TObject);
begin
Operation1:=StrToFloat(Edit1.Text);
Operation2:='/';
Edit1.Text:='';
end;
procedure TForm1.ButtonResultatClick(Sender: TObject);
var Operation3:real;
begin
Operation3:=StrToFloat(Edit1.Text);
if Operation2='+' then Edit1.Text:=FloatToStr(Operation1+Operation3);
if Operation2='-' then Edit1.Text:=FloatToStr(Operation1-Operation3);
if Operation2='x' then Edit1.Text:=FloatToStr(Operation1*Operation3);
if Operation2='/' then Edit1.Text:=FloatToStr(Operation1/Operation3);
end;
procedure TForm1.edit1KeyPress(Sender: TObject; var Key: Char);
begin
Edit1.MaxLength:=10;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
Edit1.SetFocus;
end;
end.