为何编译器会说“未声明的标识符”?当我尝试从表格A显示表格B时? [英] Why does the compiler say "undeclared identifier" when I try to show form B from form A?

查看:74
本文介绍了为何编译器会说“未声明的标识符”?当我尝试从表格A显示表格B时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么此代码不起作用:

Why this code is not working:

procedure TFormNotification.Button3Click(Sender: TObject);
begin
  FormB.Show;
end;

我收到未声明的标识符错误。

推荐答案

您可能在接口中声明了名为 FormB 的全局变量名为 UnitB 的单元的部分。但是 UnitA 对该单元或其内容一无所知。特别是,它不知道 FormB 的含义-未声明该标识符。

You probably have a global variable named FormB declared in the interface section of a unit named UnitB. But UnitA doesn't know anything about that unit or its contents. In particular, it doesn't know what the word FormB means — that identifier is undeclared.

告诉 UnitA 有关在 UnitB 中声明的内容,将 UnitB 添加到 UnitA 中的 uses子句

To tell UnitA about the things declared in UnitB, add UnitB to the uses clause in UnitA:

uses Windows, SysUtils, Forms, Classes, UnitB;

这篇关于为何编译器会说“未声明的标识符”?当我尝试从表格A显示表格B时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆