利用以下方法:
在form1里面编写函数:
function ExecuteForm1(var S : string) : word;
var
Form1 : TForm1;
begin
Form1 := TForm1.createform(application);
result := form1.showmodual;
try
if result = mrOK then
begin
S := 'OK';
end;
finally
form1.free;
end;
end;
在form1中添加按钮button,在click事件里写代码:
procedure Button1Click(sender:TObject);
begin
ModalResult := mrOk;
end;
//-----------------------------------------------------------------
在form2里面调用(首先必须uses form1单元),例如在Button1的click事件里
procedure Button1Click(sender:TObject);
var
S:string;
begin
if form1.ExecuteForm1(S) = mrOK then
begin
showmessage(S);
end;
end;