你用self.试试有没有FindComponent,很奇怪

解决方案 »

  1.   

    Function AddUp(i:integer;j:integer):integer;
    Var
      s,k:integer;
    begin
      s:=0;
      For k:=i To j do
      begin
        s:=s+StrToInt(TEDIT(Application. 或 Form1. FindComponent('Edit'+IntToStr(k))).Text)
      end;
      AddUp:=s;
    end;
      

  2.   

    哦我知道了,你的Addup不是类方法,解决办法有两个,一是调用form1的FindComponent,二是把AddUp封装到类里面去
      

  3.   

    哈哈,
    您的定义应该这样:
    function TForm1.AddUp (i:Integer;j:Integer):Integer;
    begin
      //.... to do: Add your code here
    end;
      

  4.   

    你应该在implementation下面加上声明:
    implementation
      function AddUp(i:integer;j:integer): Integer;
    {$R *.dfm}
    这样你才能在程序中将AddUp作为全局函数使用,如果不是非常有必要的话,建议不要定义全局函数,而在private中按照acqy(Just Programmer)的方法定义,呵呵
      

  5.   

    将s:=s+StrToInt(TEDIT(FindComponent('Edit'+IntToStr(k))).Text)
    换成 s:=s+StrToInt(TEDIT(Form1.FindComponent('Edit'+IntToStr(k))).Text),注意:Form1.FindComponent:
    var
      Form1: TForm1;
      ===============
    implementation