我在我创建的名为提交的过程中得到了“未声明的标识符”。
procedure submit;
begin
if ebMain.Text='exit' then
fmMain.Close;
end;
真的很简单。编译器告诉我 ebMain 未声明。我可以通过输入“fmMain”来解决这个问题。在它前面,但我从来没有在delphi 7中这样做。编辑框(ebMain)在主窗体(fmMain)上。过程标题位于“使用”下方。怎么了?
我在我创建的名为提交的过程中得到了“未声明的标识符”。
procedure submit;
begin
if ebMain.Text='exit' then
fmMain.Close;
end;
真的很简单。编译器告诉我 ebMain 未声明。我可以通过输入“fmMain”来解决这个问题。在它前面,但我从来没有在delphi 7中这样做。编辑框(ebMain)在主窗体(fmMain)上。过程标题位于“使用”下方。怎么了?
submit()
不是你TfrmMain
班级的成员,所以它不知道是什么ebMain
。您需要:
1) 成为submit()
表单类的成员(无论如何你都应该这样做,因为它所做的只是访问 的成员TfrmMain
):
procedure TfrmMain.submit;
begin
if ebMain.Text='exit' then
Close;
end;
procedure submit;
begin
frmMain.submit;
end;
ebMain
2)以表单的全局变量为前缀frmMain
(就像你已经在做的那样Close()
):
procedure submit;
begin
if frmMain.ebMain.Text='exit' then
fmMain.Close;
end;
是的,您必须在每个版本的 Delphi 中都这样做,包括 D7。