1.如何设计并实现一个整型算术计算器,计算i计高手指教下
2.ç¨delphiå计ç®å¨
3.delphi怎样调用外部EXE文件
4.DELPHI中编号了一个计算器,器源未实现除数不能为零,算器小数点不重复,源码疯狂的解析网站源码键盘录入,计算i计连加连减问题。器源人脸识别html源码高手帮忙改改。算器
如何设计并实现一个整型算术计算器,源码高手指教下
delphi写的计算i计不知道对你有帮助么
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Label1: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Button8: TButton;
Button9: TButton;
Button: TButton;
Button: TButton;
Button: TButton;
Button: TButton;
Button: TButton;
Button: TButton;
Button: TButton;
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 ButtonClick(Sender: TObject);
procedure ButtonClick(Sender: TObject);
procedure ButtonClick(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure ButtonClick(Sender: TObject);
procedure ButtonClick(Sender: TObject);
procedure ButtonClick(Sender: TObject);
procedure ButtonClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
temp1:string;
temp2:real;
n:integer;
implementation
{ $R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit1.Text:=Edit1.Text+'1'; //在运算框输入数字'1'
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Edit1.Text:=Edit1.Text+'2'; //在运算框输入数字'2'
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Edit1.Text:=Edit1.Text+'3'; //在运算框输入数字'3'
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
Edit1.Text:=Edit1.Text+'4'; //在运算框输入数字'4'
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
Edit1.Text:=Edit1.Text+'5'; //在运算框输入数字'5'
end;
procedure TForm1.Button7Click(Sender: TObject);
begin
Edit1.Text:=Edit1.Text+'6'; //在运算框输入数字'6'
end;
procedure TForm1.Button9Click(Sender: TObject);
begin
Edit1.Text:=Edit1.Text+'7'; //在运算框输入数字'7'
end;
procedure TForm1.ButtonClick(Sender: TObject);
begin
Edit1.Text:=Edit1.Text+'8'; //在运算框输入数字'8'
end;
procedure TForm1.ButtonClick(Sender: TObject);
begin
Edit1.Text:=Edit1.Text+'9'; //在运算框输入数字'9'
end;
procedure TForm1.ButtonClick(Sender: TObject);
begin
Edit1.Text:=Edit1.Text+'0'; //在运算框输入数字'0'
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
n:=1; //为加法运算设置标志变量
temp1:=Edit1.Text; //为临时变量temp1赋值
Edit1.Clear; //清空运算符
end;
procedure TForm1.Button8Click(Sender: TObject);
begin
n:=2; //为减法运算设置标志变量
temp1:=Edit1.Text; //为临时变量temp1赋值
Edit1.Clear; //清空运算符
end;
procedure TForm1.ButtonClick(Sender: TObject);
begin
n:=3; //为乘法运算设置标志变量
temp1:=Edit1.Text; //为临时变量temp1赋值
Edit1.Clear; //清空运算符
end;
procedure TForm1.ButtonClick(Sender: TObject);
begin
n:=4; //为除法运算设置标志变量
temp1:=Edit1.Text; //为临时变量temp1赋值
Edit1.Clear; //清空运算符
end;
procedure TForm1.ButtonClick(Sender: TObject);
begin
Edit1.Clear;
end;
procedure TForm1.ButtonClick(Sender: TObject);
begin
case n of
1:temp2:=strtofloat(temp1)+strtofloat(Edit1.Text);
2:temp2:=strtofloat(temp1)-strtofloat(Edit1.Text);
3:temp2:=strtofloat(temp1)*strtofloat(Edit1.Text);
4:if strtofloat(Edit1.Text)=0 then
begin
showmessage('除数不能为0!');
exit;
end
else
temp2:=strtofloat(temp1)/strtofloat(Edit1.Text);
end;
Edit1.Text:=floattostr(temp2);
end;
end.
ç¨delphiå计ç®å¨
è¿æ¯æºä»£ç ï¼
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
SpeedButton7: TSpeedButton;
SpeedButton8: TSpeedButton;
SpeedButton9: TSpeedButton;
SpeedButton: TSpeedButton;
SpeedButton4: TSpeedButton;
SpeedButton5: TSpeedButton;
SpeedButton6: TSpeedButton;
SpeedButton: TSpeedButton;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton: TSpeedButton;
SpeedButton: TSpeedButton;
SpeedButton: TSpeedButton;
SpeedButton: TSpeedButton;
StaticText1: TStaticText;
SpeedButton0: TSpeedButton;
SpeedButton: TSpeedButton;
SpeedButton: TSpeedButton;
GroupBox1: TGroupBox;
procedure SpeedButton1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure SpeedButtonClick(Sender: TObject);
procedure SpeedButtonClick(Sender: TObject);
procedure SpeedButtonClick(Sender: TObject);
procedure SpeedButtonClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
restart: Boolean;
isfirst: Boolean;
fir_num,sec_num: String;
sign: integer;
result: real;
save: String;
implementation
{ $R *.dfm}
function count(sign: integer):real;
begin
case sign of
1: result:=strtofloat(fir_num)+strtofloat(sec_num); //为å å·æ¶
2: result:=strtofloat(fir_num)-strtofloat(sec_num); //为åå·æ¶
3: result:=strtofloat(fir_num)*strtofloat(sec_num); //为ä¹å·æ¶
4: begin
try
result:=strtofloat(fir_num)/strtofloat(sec_num); //为é¤å·æ¶
except
ShowMessage('é误!');
form1.close;
end; //é¤æ°ä¸º0æ¶,ååºå¼å¸¸å¤ç
end;
end;
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
var
i: integer;
begin
if restart then //å¦ææ¯éæ°å¼å§è¾å ¥,åæ¸ é¤åæ¥çæä½æ°,并设置isfirst为True
begin
isfirst:=True;
fir_num:='';
sec_num:='';
restart:=False;
end;
if isfirst then //å¦ææ¯ç¬¬ä¸ä¸ªæä½æ°
begin
if (sender as TSpeedButton).Caption='.' then //å¦æè¾å ¥çæ¯å°æ°ç¹
begin
if (strlen(pChar(fir_num))<=0) then //å¦æ第ä¸ä¸ªæä½æ°å¹¶æªè¾å ¥
fir_num:='0.'
else
for i:= 1 to strlen(pChar(fir_num)) do
if fir_num[i]='.' then exit;
//å¦æ第ä¸ä¸ªä¸å·²å«æå°æ°ç¹èåè¾å ¥å°æ°ç¹,åéåº
end;
if (strlen(pChar(fir_num))>0) and (fir_num[1]='0') then //å¦ææé«ä½ä¸º0
begin
if ((sender as TSpeedButton).Caption='.') then
fir_num:='0.'
else
begin
if strlen(pChar(fir_num))>1 then //å¦ææ¯å°æ°,å继ç»è¾å ¥
fir_num:=fir_num+(sender as TSpeedButton).Caption
else
fir_num:=(sender as TSpeedButton).Caption;
//å¦æä¸æ¯å°æ°,åå»ææé«ä½ç0
end;
end
else
fir_num:=fir_num+(sender as TSpeedButton).Caption;
StaticText1.Caption:=fir_num;
end
else
begin
if (sender as TSpeedButton).Caption='.' then //å¦æ第äºä¸ªæä½æ°å¹¶æªè¾å ¥
begin
if (strlen(pChar(sec_num))<=0) then
sec_num:='0.'
else
for i:= 1 to strlen(pChar(sec_num)) do
if sec_num[i]='.' then exit;
//å¦æ第äºä¸ªä¸å·²å«æå°æ°ç¹èåè¾å ¥å°æ°ç¹,åéåº
end;
if (strlen(pChar(sec_num))>0) and (sec_num[1]='0') then //å¦ææé«ä½ä¸º0
begin
if ((sender as TSpeedButton).Caption='.') then
sec_num:='0.'
else
begin
if strlen(pChar(sec_num))>1 then //å¦ææ¯å°æ°,å继ç»è¾å ¥
sec_num:=sec_num+(sender as TSpeedButton).Caption
else
sec_num:=(sender as TSpeedButton).Caption;
//å¦æä¸æ¯å°æ°,åå»ææé«ä½ç0
end;
end
else
sec_num:=sec_num+(sender as TSpeedButton).Caption;
StaticText1.Caption:=sec_num;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
StaticText1.Caption:='0.'; //设置StaticText1åå§æ¾ç¤ºä¸º0.
restart:=False;
Isfirst:=True;
fir_num:='';
sec_num:='';
end;
procedure TForm1.SpeedButtonClick(Sender: TObject);
begin
if (fir_num<>'') and (sec_num<>'') then
//å¦æ两åæä½æ°é½ä¸ä¸ºç©º
begin
result:=count(sign); //è°ç¨å½æ°,è¿å计ç®ç»æ
fir_num:=floattostr(result);
sec_num:='';
StaticText1.Caption:=floattostr(result);
end;
sign:=(sender as TSpeedButton).Tag;
isfirst:=False;
restart:=False;
end;
procedure TForm1.SpeedButtonClick(Sender: TObject);
begin
if (sec_num<>'') then
//å¦æ第äºä¸ªæä½æ°ä¸ä¸ºç©ºåè¿åç»æ
begin
result:=count(sign);
fir_num:='';
fir_num:=fir_num+floattostr(result);
StaticText1.Caption:=floattostr(result);
sec_num:='';
end;
restart:=true;
end;
procedure TForm1.SpeedButtonClick(Sender: TObject);
begin
restart:=True;
fir_num:='';
sec_num:='';
self.StaticText1.Caption:='0.';
end;
procedure TForm1.SpeedButtonClick(Sender: TObject);
begin
Close;
end;
end.
delphi怎样调用外部EXE文件
delphi 调用外部 EXE 程序,可以使用以下办法:
一、器源使用 WinExec 函数,算器示例代码:WinExec('calc.exe',源码SW_NORMAL) //打开计算器二、计算i计信源码怎么去使用 ShellExecute 函数,器源示例:ShellExecute(handle,算器'open',独门绝技指标源码'c:/myapp/myapp.exe','-s',',9cc源码SW_SHOWNORMAL)
DELPHI中编号了一个计算器,未实现除数不能为零,小数点不重复,键盘录入,连加连减问题。高手帮忙改改。
//直接帮你写个计算器了吧。
//3个edit ,一个label,一个combobox事件如下
procedure TForm1.FormCreate(Sender: TObject);
begin
combobox1.Items.Add('+');
combobox1.Items.Add('-');
combobox1.Items.Add('*');
combobox1.Items.Add('/');
combobox1.ItemIndex :=0;
label1.Caption := '=';
edit1.Text := '0';
edit2.Text := '0';
edit3.Text := '0';
button1.Caption := '计算';
end;
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if not (key in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', #8]) then
key := char(0);
end;
procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
if not (key in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', #8]) then
key := char(0);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
case combobox1.ItemIndex of
0 :
begin
if (edit1.Text<>'') and (edit2.Text<>'')then
edit3.Text := floatTostr(StrTofloat(edit1.Text)+StrTofloat(edit2.Text));
end;
1 :
begin
if (edit1.Text<>'') and (edit2.Text<>'')then
edit3.Text := floatTostr(StrTofloat(edit1.Text)-StrTofloat(edit2.Text));
end;
2 :
begin
if (edit1.Text<>'') and (edit2.Text<>'')then
edit3.Text := floatTostr(StrTofloat(edit1.Text) *StrTofloat(edit2.Text));
end;
3 :
begin
if (edit1.Text<>'') and (edit2.Text<>'')and(edit2.Text<>'0')then
edit3.Text := floatTostr(StrToint(edit1.Text) /StrTofloat(edit2.Text));
end;
end;
end;