各位朋友,我是个新手,现在用的是本案例的书,很多东西不是很清楚,请各前辈指点,另不知还有什么书更合适的,以下是我在编译连接时,总是说是错的,提示为
[错误]unit1.pas(34):undeclared identifier;'form2'
[错误]unit1.pas(38):undeclared identifier:'form3'
[致命错误]project1.dpr(7):could not compile used unit'unit1.pas'procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
form2.showmodal;
end;
procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
form3.show;
end;
end.
谢谢!!!

解决方案 »

  1.   

    你需要在你的use中添加 form2和form3对应的单元文件名
      

  2.   

    楼上的说的对:       implmentation
                uses unit2,unit3;
            procedure TForm1.SpeedButton1Click(Sender: TObject);
    begin
      if not assigned(form2) then
       form2:=Tform2.create(self);
    try
    form2.showmodal;
    finally
       freeandnil(form2);
    end;
    procedure TForm1.SpeedButton2Click(Sender: TObject);
    begin
    if not assigned(form3) then
          form3:=Tform3.create(self);
        form3.show;
    end;procedure TForm1.ondestroy(Sender: TObject);
    begin
    freeandnil(form3);
    end;
      

  3.   

    implmentation
       uses unit2,unit3;//在实现部分引用unit2,unit3单元文件
      

  4.   

    你在Form1中要显示Form2和Form3
    就必须在Form1中引用Form2和Form3所在单元在implemention下面加上
    uses Unit2,Unit3;
    或者加到最开始的uses中procedure TForm1.SpeedButton1Click(Sender: TObject);
    begin
      form2.showmodal;
    end;
    procedure TForm1.SpeedButton2Click(Sender: TObject);
    begin
      form3.show;
    end;
    end.
      

  5.   

    楼主可看看《Delphi7从入门到精通》