//要点13: 需要给其他单元调用, 必须在 interface 声明, 但必须在 uses 区后面
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  end;

{需要给其他单元调用, 必须在 interface 声明, 但必须在 uses 区后面}
function MyFun(x,y: Integer): Integer; {函数声明}

var
  Form1: TForm1;

implementation

{$R *.dfm}

function MyFun(x,y: Integer): Integer; {函数实现}
begin
  Result := x + y;
end;


procedure TForm1.Button1Click(Sender: TObject);
var
  i: Integer;
begin
  i := MyFun(1,2);
  ShowMessage(IntToStr(i)); {3}
end;

end.

posted on 2008-01-14 21:32  万一  阅读(4464)  评论(5编辑  收藏  举报