编了个delphi的程。但是edit3不显示计算机结果。并且‘清空’功能按钮不能清空edit1.
unityouwenti;interfaceusesWindows,Messages,SysUtils,Variants,Classes,Graphics,Control...
unit youwenti;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm3 = class(TForm)
RadioGroup1: TRadioGroup;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Button1: TButton;
Button2: TButton;
GroupBox1: TGroupBox;
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
procedure RadioGroup1Click(Sender: TObject);
procedure CheckBox1Enter(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
procedure TForm3.Button2Click(Sender: TObject);
begin
form3.Close; //退出按钮
end;
procedure TForm3.CheckBox1Enter(Sender: TObject);
begin
if checkbox1.Checked then //清空按钮 问题出现的地方
edit1.Clear;
edit2.Clear;
edit3.Clear;
end;
procedure TForm3.RadioGroup1Click(Sender: TObject);
var
x,y,z:integer;
begin
x:=strtoint(edit1.Text);
y:=strtoint(edit2.Text);
case radiogroup1.ItemIndex of //选择运算符
0:z:=x+y;
1:z:=x-y;
2:z:=x*y;
3:z:=x div y;
end;
edit3.Text:=inttostr(z);//输出结果 问题是无结果
if radiogroup1.ItemIndex=3 then //除法的显示余数按钮选择是输出结果
if checkbox2.Checked then
edit3.Text:=edit3.Text+'余'+inttostr(x mod y);
end;
end. 展开
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm3 = class(TForm)
RadioGroup1: TRadioGroup;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Button1: TButton;
Button2: TButton;
GroupBox1: TGroupBox;
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
procedure RadioGroup1Click(Sender: TObject);
procedure CheckBox1Enter(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
procedure TForm3.Button2Click(Sender: TObject);
begin
form3.Close; //退出按钮
end;
procedure TForm3.CheckBox1Enter(Sender: TObject);
begin
if checkbox1.Checked then //清空按钮 问题出现的地方
edit1.Clear;
edit2.Clear;
edit3.Clear;
end;
procedure TForm3.RadioGroup1Click(Sender: TObject);
var
x,y,z:integer;
begin
x:=strtoint(edit1.Text);
y:=strtoint(edit2.Text);
case radiogroup1.ItemIndex of //选择运算符
0:z:=x+y;
1:z:=x-y;
2:z:=x*y;
3:z:=x div y;
end;
edit3.Text:=inttostr(z);//输出结果 问题是无结果
if radiogroup1.ItemIndex=3 then //除法的显示余数按钮选择是输出结果
if checkbox2.Checked then
edit3.Text:=edit3.Text+'余'+inttostr(x mod y);
end;
end. 展开
2个回答
展开全部
不是 CheckBox1Enter ,
是 CheckBox1Click ..
procedure TForm3.CheckBox1Click(Sender: TObject);
begin
if CheckBox1.Checked then
begin
Edit1.Clear;
Edit2.Clear;
Edit3.Clear;
end;
end;
不用 RadioGroup1Click
要用 Button1Click
z为integer, x div y 不一定是integer
如果不是integer , inttostr时会报错..
这个也要考虑进去
是 CheckBox1Click ..
procedure TForm3.CheckBox1Click(Sender: TObject);
begin
if CheckBox1.Checked then
begin
Edit1.Clear;
Edit2.Clear;
Edit3.Clear;
end;
end;
不用 RadioGroup1Click
要用 Button1Click
z为integer, x div y 不一定是integer
如果不是integer , inttostr时会报错..
这个也要考虑进去
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询