帮忙做一个delphi小程序。

[复制链接]
查看11 | 回复2 | 2010-1-23 09:15:52 | 显示全部楼层 |阅读模式
我觉得如果只是给你贴出来源代码是不太好的,毕竟里面包含了一些控件,所有你如果需要我可以将源程序传给你,那样你也方便看和理解
回复

使用道具 举报

千问 | 2010-1-23 09:15:52 | 显示全部楼层
就一个计算器吗?放一个控件不就OK吗?你只说这些,又不说详细一点。
回复

使用道具 举报

千问 | 2010-1-23 09:15:52 | 显示全部楼层
var
Form1: TForm1;
s1,s2,s3:real;
yunsuan,xiaoshudian,shuzi:integer;
m,n,k,fuhao,js:integer;
x,y:string;
ms:string;
xp,ll:string;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);varpp:string;m:integer;begin
pp:=edit1.Text;
m:=length(pp);
if m=2 then
begin
edit1.Text:='0.';
xiaoshudian:=0;
end
else
begin
if pp[m]='.' then
begin
setlength(pp,m-2);
edit1.Text:=pp+'.'
end;
if pp[m]'.' then
begin
setlength(pp,m-1);
edit1.Text:=pp;
end;
end;
end;procedure TForm1.Button2Click(Sender: TObject);begin
edit1.Text:='0.';end;procedure TForm1.Button4Click(Sender: TObject);begin
if yunsuan=0 then
begin
if xiaoshudian=0 then
begin
if edit1.Text='0.' then
begin
edit1.Text:='1.';
end
else
if edit1.Text'0.' then
begin
y:=edit1.Text;
m:=length(y);
setlength(y,m-1);
edit1.Text:=y+'1'+'.';
end;
end;
if xiaoshudian=1 then
begin
y:=edit1.Text;
edit1.Text:=y+'1';
end;
end;
if yunsuan=1 then
begin
edit1.Text:='1.';
yunsuan:=0;
xiaoshudian:=0;
end;
shuzi:=1;
if js=1 then
begin
n:=0;
js:=js-1;
end;end;procedure TForm1.Button5Click(Sender: TObject);begin
if yunsuan=0 then
begin
if xiaoshudian=0 then
begin
if edit1.Text='0.' then
begin
edit1.Text:='2.';
end
else
if edit1.Text'0.' then
begin
y:=edit1.Text;
m:=length(y);
setlength(y,m-1);
edit1.Text:=y+'2'+'.';
end;
end;
if xiaoshudian=1 then
begin
y:=edit1.Text;
edit1.Text:=y+'2';
end;
end;
if yunsuan=1 then
begin
edit1.Text:='2.';
yunsuan:=0;
xiaoshudian:=0;
end;
shuzi:=1;
if js=1 then
begin
n:=0;
js:=js-1;
end;end;procedure TForm1.Button6Click(Sender: TObject);beginif yunsuan=0 then
begin
if xiaoshudian=0 then
begin
if edit1.Text='0.' then
begin
edit1.Text:='3.';
end
else
if edit1.Text'0.' then
begin
y:=edit1.Text;
m:=length(y);
setlength(y,m-1);
edit1.Text:=y+'3'+'.';
end;
end;
if xiaoshudian=1 then
begin
y:=edit1.Text;
edit1.Text:=y+'3';
end;
end;
if yunsuan=1 then
begin
edit1.Text:='3.';
yunsuan:=0;
xiaoshudian:=0;
end;
shuzi:=1;
if js=1 then
begin
n:=0;
js:=js-1;
end;end;procedure TForm1.Button7Click(Sender: TObject);beginif yunsuan=0 then
begin
if xiaoshudian=0 then
begin
if edit1.Text='0.' then
begin
edit1.Text:='4.';
end
else
if edit1.Text'0.' then
begin
y:=edit1.Text;
m:=length(y);
setlength(y,m-1);
edit1.Text:=y+'4'+'.';
end;
end;
if xiaoshudian=1 then
begin
y:=edit1.Text;
edit1.Text:=y+'4';
end;
end;
if yunsuan=1 then
begin
edit1.Text:='4.';
yunsuan:=0;
xiaoshudian:=0;
end;
shuzi:=1;
if js=1 then
begin
n:=0;
js:=js-1;
end;end;procedure TForm1.Button8Click(Sender: TObject);beginif yunsuan=0 then
begin
if xiaoshudian=0 then
begin
if edit1.Text='0.' then
begin
edit1.Text:='5.';
end
else
if edit1.Text'0.' then
begin
y:=edit1.Text;
m:=length(y);
setlength(y,m-1);
edit1.Text:=y+'5'+'.';
end;
end;
if xiaoshudian=1 then
begin
y:=edit1.Text;
edit1.Text:=y+'5';
end;
end;
if yunsuan=1 then
begin
edit1.Text:='5.';
yunsuan:=0;
xiaoshudian:=0;
end;
shuzi:=1;
if js=1 then
begin
n:=0;
js:=js-1;
end;end;procedure TForm1.Button9Click(Sender: TObject);beginif yunsuan=0 then
begin
if xiaoshudian=0 then
begin
if edit1.Text='0.' then
begin
edit1.Text:='6.';
end
else
if edit1.Text'0.' then
begin
y:=edit1.Text;
m:=length(y);
setlength(y,m-1);
edit1.Text:=y+'6'+'.';
end;
end;
if xiaoshudian=1 then
begin
y:=edit1.Text;
edit1.Text:=y+'6';
end;
end;
if yunsuan=1 then
begin
edit1.Text:='6.';
yunsuan:=0;
xiaoshudian:=0;
end;
shuzi:=1;
if js=1 then
begin
n:=0;
js:=js-1;
end;end;procedure TForm1.Button10Click(Sender: TObject);beginif yunsuan=0 then
begin
if xiaoshudian=0 then
begin
if edit1.Text='0.' then
begin
edit1.Text:='7.';
end
else
if edit1.Text'0.' then
begin
y:=edit1.Text;
m:=length(y);
setlength(y,m-1);
edit1.Text:=y+'7'+'.';
end;
end;
if xiaoshudian=1 then
begin
y:=edit1.Text;
edit1.Text:=y+'7';
end;
end;
if yunsuan=1 then
begin
edit1.Text:='7.';
yunsuan:=0;
xiaoshudian:=0;
end;
shuzi:=1;
if js=1 then
begin
n:=0;
js:=js-1;
end;end;procedure TForm1.Button11Click(Sender: TObject);beginif yunsuan=0 then
begin
if xiaoshudian=0 then
begin
if edit1.Text='0.' then
begin
edit1.Text:='8.';
end
else
if edit1.Text'0.' then
begin
y:=edit1.Text;
m:=length(y);
setlength(y,m-1);
edit1.Text:=y+'8'+'.';
end;
end;
if xiaoshudian=1 then
begin
y:=edit1.Text;
edit1.Text:=y+'8';
end;
end;
if yunsuan=1 then
begin
edit1.Text:='8.';
yunsuan:=0;
xiaoshudian:=0;
end;
shuzi:=1;
if js=1 then
begin
n:=0;
js:=js-1;
end;end;procedure TForm1.Button12Click(Sender: TObject);beginif yunsuan=0 then
begin
if xiaoshudian=0 then
begin
if edit1.Text='0.' then
begin
edit1.Text:='9.';
end
else
if edit1.Text'0.' then
begin
y:=edit1.Text;
m:=length(y);
setlength(y,m-1);
edit1.Text:=y+'9'+'.';
end;
end;
if xiaoshudian=1 then
begin
y:=edit1.Text;
edit1.Text:=y+'9';
end;
end;
if yunsuan=1 then
begin
edit1.Text:='9.';
yunsuan:=0;
xiaoshudian:=0;
end;
shuzi:=1;
if js=1 then
begin
n:=0;
js:=js-1;
end;end;procedure TForm1.Button13Click(Sender: TObject);beginif yunsuan=0 then
begin
if xiaoshudian=0 then
begin
if edit1.Text='0.' then
begin
edit1.Text:='0.';
end
else
if edit1.Text'0.' then
begin
y:=edit1.Text;
m:=length(y);
setlength(y,m-1);
edit1.Text:=y+'0'+'.';
end;
end;
if xiaoshudian=1 then
begin
y:=edit1.Text;
edit1.Text:=y+'0';
end;
end;
if yunsuan=1 then
begin
edit1.Text:='0.';
yunsuan:=0;
xiaoshudian:=0;
end;
shuzi:=1;
if js=1 then
begin
n:=0;
js:=js-1;
end;end;procedure TForm1.Button14Click(Sender: TObject);begin
xiaoshudian:=1;end;procedure TForm1.Button15Click(Sender: TObject);vari,j:integer;begin
if (n in [1,2,3,4]) then
begin
if shuzi=1 then
begin
s3:=strtofloat(edit1.Text);
s2:=s3;
case n of
1:x:=floattostr(s1+s2)+'.';
2:x:=floattostr(s1-s2)+'.';
3:x:=floattostr(s1*s2)+'.';
4:if s2=0 then
begin
x:='0.';
end
else
begin
x:=floattostr(s1/s2)+'.';
end;
end;
js:=1;end;
if shuzi=0 then
begin
s2:=s3;
s1:=strtofloat(edit1.Text);
case n of
1:x:=floattostr(s1+s2)+'.';
2:x:=floattostr(s1-s2)+'.';
3:x:=floattostr(s1*s2)+'.';
4:if s2=0 then
begin
x:='0.';
end
else
begin
x:=floattostr(s1/s2)+'.'
end;
end;
js:=1;
end;
j:=0;
k:=length(x);
for i:=1 to k do
if x='.' then
begin
j:=j+1;
end;
if j>1 then
begin
setlength(x,k-1);
edit1.Text:=x;
yunsuan:=1;
shuzi:=0;
end
else
begin
edit1.Text:=x;
yunsuan:=1;
shuzi:=0;
end;
end;end;procedure TForm1.Button16Click(Sender: TObject);begins1:=strtofloat(edit1.Text);
n:=1;
yunsuan:=1;
if js=1 then
begin
js:=js+1;
end;end;procedure TForm1.Button17Click(Sender: TObject);begin
s1:=strtofloat(edit1.Text);
n:=2;
yunsuan:=1;
if js=1 then
begin
js:=js+1;
end;end;procedure TForm1.Button18Click(Sender: TObject);begin
s1:=strtofloat(edit1.Text);
n:=3;
yunsuan:=1;
if js=1 then
begin
js:=js+1;
end;end;procedure TForm1.Button19Click(Sender: TObject);begin
s1:=strtofloat(edit1.Text);
n:=4;
yunsuan:=1;
if js=1 then
begin
js:=js+1;
end;end;procedure TForm1.Button21Click(Sender: TObject);beginclose;end;procedure TForm1.Button22Click(Sender: TObject);varxx:string;yy:string;j:integer;begin
if fuhao=0 then
begin
xx:=edit1.Text;
edit1.Text:='-'+xx;
fuhao:=1;
end
else
if fuhao=1 then
begin
yy:=edit1.Text;
j:=pos('-',yy);
delete(yy,j,1);
edit1.Text:=yy;
fuhao:=0;
end;end;procedure TForm1.Button23Click(Sender: TObject);varx1,x2:real;x3:string;x4,x5,j:integer;begin
x1:=strtofloat(edit1.Text);
x2:=(x1/100);
x3:=floattostr(x2);
x4:=length(x3);
j:=0;
for x5:=1 to x4 do
if x3[x5]='.' then
j:=j+1;
if j=1 then
begin
edit1.Text:=x3;
end;
if j=0 then
begin
x2:=sqrt(x1);
x3:=floattostr(x2);
x4:=length(x3);
j:=0;
for x5:=1 to x4 do
if x3[x5]='.' then
j:=j+1;
if j=1 then
begin
edit1.Text:=x3;
end;
if j<1 then
begin
edit1.Text:=x3+'.';
end;
end;
yunsuan:=1;
js:=0;
n:=0;end;end.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行