delphi计算器之数学函数(一个简单的问题)

作者&投稿:穰凤 (若有异议请与网页底部的电邮联系)
delphi问题(简单计算机)高手进!!!在线等~

根本就是循环写错了。。。。。。
begin
if combobox1.Text = '+' then;

end;

应该是
if combobox1.Text = '+' then
begin
vt3:=vt1+vt2;
memo1.Text:=floattostr(vt3);

end;

其他自己想。

试试这个

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;

type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
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;
Button17: TButton;
procedure Button4Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure Button10Click(Sender: TObject);
procedure Button11Click(Sender: TObject);
procedure Button13Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button12Click(Sender: TObject);
procedure Button15Click(Sender: TObject);
procedure Button16Click(Sender: TObject);
procedure Button17Click(Sender: TObject);
procedure Button14Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
procedure SetEditText(info: string);
{ Private declarations }
public
{ Public declarations }
end;
type //自定义一个Tcompute的类

Tcompute = object
private //保护类中成员数据的安全

temp1: double;
temp2: double;
temp3: double;
sign: Char;

public //把类中的成员函数进行共享


function Add(x: double; y: double): Double;
function Sub(x: double; y: double): Double;
function Mult(x: double; y: double): Double;
function Dived(x: double; y: double): Double;

end;
var
Form1: TForm1;
Info: Tcompute; //声明Info是类Tcompute的对象
oldinfo:string;


implementation

function Tcompute.Add(x: double; y: double): Double; //进行类的定义与实现

begin
Result := x + y;
end;

function Tcompute.Sub(x: double; y: double): Double;
begin
Result := x - y;
end;

function Tcompute.Mult(x: double; y: double): Double;
begin
Result := x * y;
end;

function Tcompute.Dived(x: double; y: double): Double;
begin
if (y = 0) then begin
Form1.Edit1.text:='1111111111';
//ShowMessage('除数不能为0!'); //这里判断除数不能为0
Result := x;
end else
Result := x / y;
end;

{$R *.dfm}

procedure TForm1.Button4Click(Sender: TObject);
begin
oldinfo := '';
SetEditText('');
Info.sign := ' ';
Info.temp1 := 0;
Info.temp2 := 0;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
SetEditText('7');
Info.temp1 := StrTofloat(Edit1.text);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
SetEditText('8');
Info.temp1 := StrTofloat(Edit1.text);
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
SetEditText('9');
Info.temp1 := StrTofloat(Edit1.text);
end;

procedure TForm1.Button5Click(Sender: TObject);
begin
SetEditText('4');
Info.temp1 := StrTofloat(Edit1.text);
end;

procedure TForm1.Button6Click(Sender: TObject);
begin
SetEditText('5');
Info.temp1 := StrTofloat(Edit1.text);
end;

procedure TForm1.Button7Click(Sender: TObject);
begin
SetEditText('6');
Info.temp1 := StrTofloat(Edit1.text);
end;

procedure TForm1.Button9Click(Sender: TObject);
begin
SetEditText('1');
Info.temp1 := StrTofloat(Edit1.text);
end;

procedure TForm1.Button10Click(Sender: TObject);
begin
SetEditText('2');
Info.temp1 := StrTofloat(Edit1.text);
end;

procedure TForm1.Button11Click(Sender: TObject);
begin
SetEditText('3');
Info.temp1 := StrTofloat(Edit1.text);
end;

procedure TForm1.Button13Click(Sender: TObject);
begin
SetEditText('0');
Info.temp1 := StrTofloat(Edit1.text);
end;

procedure TForm1.Button8Click(Sender: TObject);
begin
Button17Click(nil);
Info.temp2 := Info.temp1;
Info.sign := '+';
oldinfo := '';
end;

procedure TForm1.Button12Click(Sender: TObject);
begin
Button17Click(nil);
Info.temp2 := Info.temp1;
Info.sign := '-';
oldinfo := '';
end;

procedure TForm1.Button15Click(Sender: TObject);
begin
Button17Click(nil);
Info.temp2 := Info.temp1;
Info.sign := '*';
oldinfo := '';
end;

procedure TForm1.Button16Click(Sender: TObject);
begin
Button17Click(nil);
Info.temp2 := Info.temp1;
Info.sign := '/';
oldinfo := '';
end;

procedure TForm1.Button17Click(Sender: TObject);
begin
if Info.sign' ' then oldinfo := '';
if (Info.sign = '+') then
SetEditText(FloatToStr(Info.Add(Info.temp2, Info.temp1)))
else if (Info.sign = '-') then
SetEditText(FloatToStr(Info.Sub(Info.temp2, Info.temp1)))
else if (Info.sign = '*') then
SetEditText(FloatToStr(Info.Mult(Info.temp2, Info.temp1)))
else if (Info.sign = '/') then
SetEditText(FloatToStr(Info.Dived(Info.temp2, Info.temp1)));
if Edit1.Text'' then
Info.temp1 := StrToFloat(Edit1.Text);
Info.sign := ' ';
end;

procedure TForm1.Button14Click(Sender: TObject);
begin
SetEditText('.');
Info.temp1 := StrToFloat(Edit1.Text);
end;

procedure TForm1.SetEditText(info:string);
begin
Edit1.Text := oldinfo + info;
oldinfo := Edit1.Text;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
oldinfo := '';
end;

end.

abs(x) 绝对值
arctan(x) 反正切
cos(x)
exp(x) e的x次幂
frac(x) 取小数部分
int(x) 取整
ln(x) 自然对数
sin(x)
sqr(x) x*x
sqrt(x) 平方根
pred(x) pred('D')='C', pred(true)=1;
succ(x) succ('Y')='Z', succ(pred(x))=x
ord(x) 求x在字符集中的序号,如ord('A')=65
chr(x) chr(65)='A'
round(x) 四舍五入
trunc(x) trunc(4.8)=4,trunc('-3.6')=-3
upcase(x) upcase('a')='A'


电讯技术投稿,稿件文字复制比不高于多少才能通过?
在D elphi,视觉,基本的Visual FoxPro中,帕斯卡和其他语言的情况下,表达的意思是一样的,所以写作时使用该协议的第一个字母,如:写一个字,如果然后,文件打开,关闭文件等。 控件,组件及其他常用词的拼写是否正确,还应当指出,不出现的情况下丢失(或更多)的字母,排序混乱,不规范的现象,可以发现在屏幕图像严格根据英语...

delphi125%字体模糊
题主是否想询问“elphi 125%缩放下字体模糊怎么办”?1、首先,在桌面上右键单击,选择“显示设置”。2、然后,在“缩放和布局”下,找到“缩放”选项,将其设置为 100%。3、最后,重新启动 Delphi 程序,查看是否已经解决问题。

qq 中.db的文件怎样查看
.db文件是数据库文件,只有用支持.db格式的数据库软件才能够打开,比如:access mysql 或者是elphi 、VB、VC等等编程类软件都可以打开的。但显示 的数据方式不一定一样。有些专用软件DB数据是加密不公开的,普通方式还无法正常打开,或者说打开时乱码 ...

delphi2007 怎么能动态的设置dll的输出路径
只要编译上面的代码,就可以玫揭桓雒 狣elphi.dll的动态链接库。现在,让我们来看看有哪些需要注意的地方: 1.在DLL中编写的函数或过程都必须加上stdcall调用参数。在Delphi 1或Delphi 2环境下该调用参数是far。从Delphi 3以后将这个参数变为了stdcall,目的是为了使用标准的Win32参数传递技术来代替优化的register参数。

Delphi dll声明方式
只要编译上面的代码,就可以玫揭桓雒�狣elphi.dll的动态链接库。现在,让我们来看看有哪些需要注意的地方: 1.在DLL中编写的函数或过程都必须加上stdcall调用参数。在Delphi 1或Delphi 2环境下该调用参数是far。从Delphi 3以后将这个参数变为了stdcall,目的是为了使用标准的Win32参数传递技术来代替优化的register参数...

电感的计算公式是怎么样的??
2、L=phi\/i(在电路中,当电流流过导体时,会产生电磁场,电磁场的大小除以电流的大小就是电感)。3、电感是导线内通过交流电流时,在导线的内部及其周围产生交变磁通,导线的磁通量与生产此磁通的电流之比。4、电感定义式L=Ψ\/I,意义是单位电流引起线圈的磁通量。电感器件电感量的计算公式:方法1、...

我在用delphi2007打开一个delphi工程文件的时候,出现下列错误: 请高手...
只要编译上面的代码,就可以玫揭桓雒�狣elphi.dll的动态链接库。现在,让我们来看看有哪些需要注意的地方: 1.在DLL中编写的函数或过程都必须加上stdcall调用参数。在Delphi 1或Delphi 2环境下该调用参数是far。从Delphi 3以后将这个参数变为了stdcall,目的是为了使用标准的Win32参数传递技术来代替优化的register参数...

求下面程序的注释,程序能否运行?为什么我运行不出结果呢?
只要编译上面的代码,就可以玫揭桓雒�狣elphi.dll的动态链接库。现在,让我们来看看有哪些需要注意的地方: 1.在DLL中编写的函数或过程都必须加上stdcall调用参数。在Delphi 1或Delphi 2环境下该调用参数是far。从Delphi 3以后将这个参数变为了stdcall,目的是为了使用标准的Win32参数传递技术来代替优化的register参数...

如何向电脑爱好者投稿?
在D elphi、Visual、Basic、Visual、FoxPro、Pascal等语言中,大小写所表示的意义是相同的,因此,在书写时采用单词首字母大写的约定,如: Write、If、Then、FileOpen、FileClose等。对控件、构件及普通单词等还应注意拼写正确,不要出现缺(或多)字母、排序混乱、大小写不规范的现象,能在屏幕图中找到的严格按图中英文...

朝鲜半岛
(Mak),Vicaria callosa Jenkins,Dentalium Complexum Dall;有孔虫:Pseudoelphidiellasubcarinata(Volosh),Ammoniaex,gr,nipponica(Asano),Ammonia beccarii(Linne),Nonionella stella Cushman et Moyer,Discorbis brady(Cushman),Buliminella elegantissima(Orbigny),Glabratella nitida(Williamson),Siphogenerina transversa(...

苏尼特右旗15693956366: delphi计算器之数学函数(一个简单的问题) -
种迹息韵: abs(x) 绝对值 arctan(x) 反正切 cos(x) exp(x) e的x次幂 frac(x) 取小数部分 int(x) 取整 ln(x) 自然对数 sin(x) sqr(x) x*x sqrt(x) 平方根 pred(x) pred('D')='C', pred(true)=1; succ(x) succ('Y')='Z', succ(pred(x))=x ord(x) 求x在字符集中的序号,如ord('A')=65 chr(x) chr(65)='A' round(x) 四舍五入 trunc(x) trunc(4.8)=4,trunc('-3.6')=-3 upcase(x) upcase('a')='A'

苏尼特右旗15693956366: delphi 如何编写一个计算体积的函数?
种迹息韵: function vector(length,width,heightinteger;beginResult:=length * width * height;end;

苏尼特右旗15693956366: delphi 如何实现:用某函数把 str 变成数学表达式,并计算出结果?
种迹息韵: 判断str 是否为运算符号,否,则把str 赋给一个字符串,是,则把符号赋给另一个字符串,然后组合.

苏尼特右旗15693956366: 用delphi编写函数求一个数组中的最大值和最小值 -
种迹息韵: //求最大值 function GetMaxInArray(A: array of Integer): Integer; var I: Integer; tmpMax: Integer; begin tmpMax := A[0]; for I := low(A) to High(A) do begin if A[I] > tmpMax then tmpMax := A[I]; end; Result := tmpMax; end;//求最小值 function ...

苏尼特右旗15693956366: 用DELPHI编写一个函数 -
种迹息韵: 不会DELPHI,用C写个,你改成DELPHI吧,程序很简单,语法应该差不多.int[] getnum() { srand((unsigned)time(NULL)); int[] num=int[8]; int i=0,is0=0; while(1) { int r=rand()%10; if(r==0) { if(is0==0){ is0=1; i++ } else continue; } else { int iscon=0; ...

苏尼特右旗15693956366: 在DELPHI有没有一个函数,随机给出一个值?????急急急!!!!!
种迹息韵: y,x:integer; beginx:=7;randomize;y:=random(7);end;var//产生的y值是个整数 在[0..6]中

苏尼特右旗15693956366: DelPhi编程中怎样自定义一个函数
种迹息韵: function abc: Integer; begin result := 0; end;

苏尼特右旗15693956366: delphi7中,用循环结构编写一个函数,找出1~100之间的素数 -
种迹息韵: //求取1到wide的之间的所有素数 procedure TForm1.showAllPrime(wide: integer); var iCount:integer; begin //排除掉1,1不是素数,不是质数,也不是合数 for iCount:=2 to wide do begin if isPrime(iCount) then begin showMessage(intTostr(iCount)+'...

苏尼特右旗15693956366: delphi中ParamCount函数有什么用?怎么用? -
种迹息韵: Delphi提供了访问命令行参数的方便的方式,那就是使用ParamStr和ParamCount函数.其中ParamStr(0)返回的是当前程序名,如C:TESTMYPROG.EXE,ParamStr(1)返回第一个参数,以此类推;ParamCount:应用程序的参数个数 典型用法一、 writeln('你输入了',ParamCount,'个参数'); 典型用法二、 if ParamCount 典型用法三、 var i:integer; begin for i:=1 to ParamCount do writeln('第',i,'个参数是:',ParamStr(i)); end.

苏尼特右旗15693956366: Delphi的函数的定义是什么?什么样的函数算是Delphi的函数?
种迹息韵: //比如定义一个求最大值的函数 fucion Max(a,b:Integer):Integer; //下面是函数内容 var m:Integer; begin if a>b then m:=a else m:=b; Max:=m;//最大值赋值给Max end; 可以说这个是函数的通用格式; 在主程序调用的时候输入两个数就可以了 比如 x:=1 y:=2 用z来记录最大值 可以这样调用函数 z:=Max(1,2);

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网