【原创源码】一个很low的计算器
本帖最后由 Survivor 于 2016-7-15 10:22 编辑回帖有奖80%中奖率
运行截图:
http://www.52pojie.cn/forum.php?mod=image&aid=693561&size=300x300&key=847c697d6b96d249&nocache=yes&type=fixnone
源码如下:unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, jpeg, ExtCtrls;
type
TForm1 = class(TForm)
edt1: TEdit;
edt2: TEdit;
edt3: TEdit;
lbl1: TLabel;
lbl2: TLabel;
btn1: TButton;
btn2: TButton;
btn3: TButton;
btn4: TButton;
btn5: TButton;
btn7: TButton;
btn8: TButton;
btn6: TButton;
edt0: TEdit;
img1: TImage;
procedure btn1Click(Sender: TObject);
procedure btn2Click(Sender: TObject);
procedure btn3Click(Sender: TObject);
procedure btn4Click(Sender: TObject);
procedure btn5Click(Sender: TObject);
procedure edt1Click(Sender: TObject);
procedure edt2Click(Sender: TObject);
procedure btn7Click(Sender: TObject);
procedure btn8Click(Sender: TObject);
procedure btn6Click(Sender: TObject);
procedure edt1Change(Sender: TObject);
procedure edt2Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
temp: Real;
i:Cardinal =0;
formula,formula1,formula2 :string;
implementation
{$R *.dfm}
procedure TForm1.btn1Click(Sender: TObject);
begin
if (i<1) then
begin
lbl1.Caption := '+';
temp:= StrToFloat(edt1.Text )+ StrToFloat(edt2.Text );
edt3.Text:=FloatToStr(temp ) ;
formula :=formula1 +'+'+formula2;
edt0.Text :=formula +'='+edt3.Text ;
end
else
begin
lbl1.Caption := '+';
temp:= StrToFloat(edt1.Text )+ StrToFloat(edt2.Text );
edt3.Text:=FloatToStr(temp ) ;
formula :=formula1 +'+'+formula2;
edt0.Text :=formula +'='+edt3.Text ;
end
end;
procedure TForm1.btn2Click(Sender: TObject);
begin
if (i<1) then
begin
lbl1.Caption := '-';
temp:= StrToFloat(edt1.Text )- StrToFloat(edt2.Text );
edt3.Text:=FloatToStr(temp ) ;
formula :=formula1 +'-'+formula2;
edt0.Text :=formula +'='+edt3.Text ;
end
else
begin
lbl1.Caption := '-';
temp:= StrToFloat(edt1.Text )- StrToFloat(edt2.Text );
edt3.Text:=FloatToStr(temp ) ;
formula :=formula1 +'-'+formula2;
edt0.Text :=formula +'='+edt3.Text ;
end
end ;
procedure TForm1.btn3Click(Sender: TObject);
begin
if (i<1) then
begin
lbl1.Caption :='×';
temp:= StrToFloat(edt1.Text )* StrToFloat(edt2.Text );
edt3.Text:=FloatToStr(temp ) ;
formula :=formula1 +'×'+formula2;
edt0.Text :=formula +'='+edt3.Text ;
end
else
begin
lbl1.Caption :='×';
temp:= StrToFloat(edt1.Text )* StrToFloat(edt2.Text );
edt3.Text:=FloatToStr(temp ) ;
formula :='('+formula1 +')'+'×'+'('+formula2+')';
edt0.Text :=formula +'='+edt3.Text ;
end
end;
procedure TForm1.btn4Click(Sender: TObject);
begin
if (i<1) then
begin
lbl1.Caption :='÷';
temp:= StrToFloat(edt1.Text )/ StrToFloat(edt2.Text );
edt3.Text:=FloatToStr(temp ) ;
formula :=formula1 +'÷'+formula2;
edt0.Text :=formula +'='+edt3.Text ;
end
else
begin
lbl1.Caption :='÷';
temp:= StrToFloat(edt1.Text )/ StrToFloat(edt2.Text );
edt3.Text:=FloatToStr(temp ) ;
formula :='('+formula1 +')'+'÷'+'('+formula2+')';
edt0.Text :=formula +'='+edt3.Text ;
end
end ;
procedure TForm1.btn5Click(Sender: TObject);
begin
lbl1.Caption :='?';
edt1.Text:='0';
edt2.Text :='0';
edt3.Text :='0';
temp :=0;
formula :=' ';
formula1 :=' ';
formula2 :=' ';
i :=0;
end;
procedure TForm1.edt1Click(Sender: TObject);
begin
edt1.SelectAll ;
end;
procedure TForm1.edt2Click(Sender: TObject);
begin
edt2.SelectAll ;
end;
procedure TForm1.btn7Click(Sender: TObject);
begin
inc (i);
edt1.Text:=edt3.Text ;
formula1 :=formula ;
edt2.SetFocus ;
edt2.SelectAll ;
end;
procedure TForm1.btn8Click(Sender: TObject);
begin
inc (i);
edt2.Text:=edt3.Text ;
formula2 :=formula ;
edt1.SetFocus ;
edt1.SelectAll ;
end;
procedure TForm1.btn6Click(Sender: TObject);
begin
Close ;
end;
procedure TForm1.edt1Change(Sender: TObject);
begin
formula1:=edt1.Text;
end;
procedure TForm1.edt2Change(Sender: TObject);
begin
formula2:=edt2.Text;
end;
end.
赵中成 发表于 2016-7-6 15:54
百分之八十,那我发俩是不是160了
你发2次能中奖的概率是 96%
类推 你发三次 能中奖的概率是 99.2%
计算器最好 最好 能走 文本公式 递归操作
wangsheng66 发表于 2016-7-20 16:53
这个表情你应该记得吧。
你以为你换个头像我就不认识你了吗{:1_912:} 为什么说这个计算器low呢 我也想问,楼主为什么low呢? 80%的中奖概率啊。。。 百分之八十,那我发俩是不是160了 真是LOW啊 这计算器功能好像有点单调~ 这么low为什么发呢 没有用,帮楼主顶