下面是整个的代码,我加的代码已经注释了。unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}
function he(a :integer;b:integer):integer; //我加的
begin //我加的
he := a * b; //我加的
end; //我加的
procedure TForm1.Button1Click(Sender: TObject);
begin
edit3.Text:= inttostr(he(strtoint(edit1.text),strtoint(edit2.text))) //我加的
end;end.
[Error] Unit1.pas(31): Undeclared identifier: 'edit3'
[Error] Unit1.pas(31): Undeclared identifier: 'edit1'
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
错误该怎么改呢? 听说少了edit3.Text这个控件,不知道是不是? 能帮我编译一下就最好了啊!我只在form中创建了一个button,然后把代码加入。
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}
function he(a :integer;b:integer):integer; //我加的
begin //我加的
he := a * b; //我加的
end; //我加的
procedure TForm1.Button1Click(Sender: TObject);
begin
edit3.Text:= inttostr(he(strtoint(edit1.text),strtoint(edit2.text))) //我加的
end;end.
[Error] Unit1.pas(31): Undeclared identifier: 'edit3'
[Error] Unit1.pas(31): Undeclared identifier: 'edit1'
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
错误该怎么改呢? 听说少了edit3.Text这个控件,不知道是不是? 能帮我编译一下就最好了啊!我只在form中创建了一个button,然后把代码加入。
解决方案 »
- Undeclared identifier: 'PBindInfo'
- DELPHI压缩文件夹--修改(网上找到一段代码,但是文件夹较大的时候会无法处理),如何修改
- 谁给我找一份工作
- RvDataSetConnection1通过ado跟sql中的表连,建立dataview时提示dataview1 exists错误,
- 初学者的ado问题,高手指点。
- sendmessage问题
- [翻出以前个老贴]大家乐一乐,不要憋坏了(超级搞笑)
- 怎样才能使装98的机器能访问局域网中安装2000的机器上的共享文件?
- 如何使用delphi里的timer控件?
- 求解一个问题的思路.
- sql中建表注意点
- delphi新手请教如何实现点击Button,然后在DBGrid中显示access数据
1:function he(a :integer;b:integer):integer;没有声明
且定义函数时该是
function TForm1.he(a :integer;b:integer):integer;
2:自定义函数中没有返回值,
可以是:result he;而且he没有定义
3:‘我只在form中创建了一个button,然后把代码加入。’
难道你edit1, edit2,edit3也没加吗?
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}function he(a :Integer; b:Integer):Integer;
begin
Result := a * b;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit3.Text := IntToStr(he(StrToInt(Edit1.Text),StrToInt(Edit2.Text)));
end;end.
Edit2: TEdit;
Edit3: TEdit;
function TForm1.he(a :integer;b:integer):integer;
1楼你给的这个函数定义我加入代码中了,可是不能编译, 下面是代码。
要把 Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
加入后才可以, 可是直接按3楼的代码就可以了啊, 这样声明、定义function不是多余了吗? 不解?unit Unit1;interface uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type
TForm1 = class(TForm)
Button1: TButton; procedure Button1Click(Sender: TObject);
function he(a :Integer; b:Integer):integer;
private
{ Private declarations }
public
{ Public declarations } end; var Form1: TForm1; implementation{$R *.dfm} function TForm1.he(a :Integer;b:Integer):integer;begin
Result := a * b;
end;procedure TForm1.Button1Click(Sender: TObject);begin
Edit3.Text := IntToStr(he(StrToInt(Edit1.Text),StrToInt(Edit2.Text)));
end;end.
区域写是有区别的
关于函数/过程的声明你可以看看 万一老师 的Delphi博客