我试过了,没有你说的问题:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
k:integer;
implementation
uses
unit2;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
k:=23;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
form2:=tform2.Create(application);
form2.show;
end;
end.
--------------------------------------------
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 = class(TForm)
Edit1: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses
unit1;
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
edit1.Text:=inttostr(unit1.k);
end;
end.