Why does the compiler say “undeclared identifier” when I try to show form B from form A?

被刻印的时光 ゝ 提交于 2019-12-10 17:49:41

问题


Why this code is not working:

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

I'm getting Undeclared identifier error.


回答1:


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.

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

uses Windows, SysUtils, Forms, Classes, UnitB;



回答2:


You need to add the unit in which FormB is declared to your uses clause.



来源:https://stackoverflow.com/questions/4404206/why-does-the-compiler-say-undeclared-identifier-when-i-try-to-show-form-b-from

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!