我做了3个Form现在在每个Form中都可能调用一个SendDate的函数,于是我想把SendDate这个函数放到公共的Unit2中放置完毕,那么如何从其他Form中调用这个SendDate函数呢??是不是要引入Unit2什么的语法,请各位给我指点指点??

解决方案 »

  1.   

    不行呀??
    总是错误提示:
    [Error]Unit1.pas(56):Undeclared identifier:'sendDate'
    [Fatal Error]Project1.dpr(7):Could not compile used unit 'Unit1.pas'---------------
    我得SendDate函数是这样的
    function SendDate(a:string; b: string): string;
    begin
            Result:=IntToStr(StrToInt(a)*StrToInt(b));
            SendDate:=Result;
    end;
      

  2.   

    你在unit1中调用unit2的函数的时候需要在函数的前面加上窗体的名字,如form2.SendDate,这样才可以的。
      

  3.   

    function SendDate(a:string; b: string): string;
    begin
            Result:=IntToStr(StrToInt(a)*StrToInt(b));
            SendDate:=Result;
    end;怎么你有个公共变量名字也叫 SendDate?  命名好一点 这样容易混淆。。公共的函数可以放到一个unit去 注意 只是unit没有dfm..的。。
      

  4.   

    在uses里放上unit2调用的时候
    unit2.sendDate();
    应该不会出错了
      

  5.   

    在接口部分声明
    function SendDate(a:string; b: string): string;在其他单元中uses unit2
      

  6.   

    或者在implementation之前声明一下
      

  7.   

    var
      Form1: TForm1;function SendDate(a:string; b: string): string;
    implementation{$R *.dfm}
    function SendDate(a:string; b: string): string;
    begin
            Result:=IntToStr(StrToInt(a)*StrToInt(b));
            SendDate:=Result;
    end;
      

  8.   

    不如先做一个base窗体,在这个窗体中增加senddate函数,然后这3个窗体都继承自这个窗体。