我用第二个窗体调用第一个自定义事件有错误.
我要在第二个窗体里调用第一个窗体中自定义的事件为什么不好用啊!
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure sum; //定义事件;
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.sum;
var
i:string;
begin
i:='我是李小明';
showmessage(i);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
sum;
end;
第二个窗体调用.
procedure TForm2.Button1Click(Sender: TObject);
begin
unit1.sum;
end;
错误信息是:0[Error] Unit2.pas(28): Undeclared identifier: 'unit1'
[Fatal Error] Unit1.pas(27): Could not compile used unit 'Unit2.pas'