我在delphi6.0中添加一个自定义函数,在type里面声明了函数名称,在implementation下面定义了函数体,格式什么都没有问题,但是当我要编译的时候就跳走了,所有我添加的东西都没有了,不知道为什么,有没有哪个大哥知道什么原因阿?

解决方案 »

  1.   

    unit Unit2;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, Buttons;type
      TForm2 = class(TForm)
        BitBtn1: TBitBtn;
        procedure BitBtn1Click(Sender: TObject);
      private
        { Private declarations }
        function aaa:string;
      public
        { Public declarations }
      end;var
      Form2: TForm2;implementation{$R *.dfm}{ TForm2 }function TForm2.aaa: string;
    begin
      Result:='hello world';
    end;procedure TForm2.BitBtn1Click(Sender: TObject);
    begin
    showmessage( aaa );
    end;end.
      

  2.   

    呵呵,用Private的方法比较好,谢谢!