程序一中:(Unit1)
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
private
{ Private declarations }
public
function Sum(var i,j:integer):integer;//函数
procedure Msg(var s:string); //过程
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Msg(var s: string);
begin
showmessage(s);
end;
function TForm1.Sum(var i, j: integer): integer;
begin
result:=i+j;
end;
end.
程序二中:(Unit2)
unit2
...
implementation
uses Unit1;
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
var
s:string;
i,j,sum:integer;
begin
//函数
i:=3;j:=5;
sum:=Form1.Sum(i,j);
showmessage(inttostr(sum));
//过程
s:='你好呀!';
form1.Msg(s);
end;
end.