有两个label,分别的name为label1,label2,我自己定义了一个过程:procedure setl(s:string);  //设置两个label同caption
begin
  Label1.caption:=s;
  Label2.caption:=label1.caption;
end;运行时产生的错误:
[Error] Unit1.pas(35): Undeclared identifier: 'Label1'
[Error] Unit1.pas(36): Undeclared identifier: 'label2'为什么会这样,应当怎样改啊?谢谢帮忙!

解决方案 »

  1.   

    如果你LABLE的窗体为FORM1
    则把此过程名改为procedure form1.set1(s:string);就可以了
      

  2.   

    procedure setl(s:string);  //设置两个label同caption
    begin
      Label1.caption:=s;
      Label2.caption:=label1.caption;
    end;改成:
    procedure setl(s:string);  //ÉèÖÃÁ½¸ölabelͬcaption
    begin
      form1.Label1.caption:=s;
      form1. Label2.caption:=form1.label1.caption;
    end;或者
    在private下定义:procedure setl(s:string);
    代码改成
    procedure form1.setl(s:string);  //设置两个label同caption
    begin
      Label1.caption:=s;
      Label2.caption:=label1.caption;
    end;