我在unit1里有一个form1 登录的
登录成功以后要运行unit2里的form2
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
unit2,Dialogs, StdCtrls, DB, ADODB;type
TForm1 = class(TForm) Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
DataSource1: TDataSource;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject); var
LoginCount: Integer;
begin LoginCount := 0;
with ADOQuery1 do
begin
Close;sql.Add('select * from users where id=:username');
parameters.ParamByName('username').Value :=trim(Edit1.Text );
open;
end;
if ADOQuery1.FieldByName('pwd').AsString =trim(Edit2.Text ) then
begin
Form1.Hide ; Tform2.Show;application.MessageBox('成功!','系统提示',0+64);end
else
begin
application.MessageBox('密码或者用户名错误,请确认!','系统提示',0+64);end;
end;end.
但是 Tform2.Show; 这句报错 意思是找不到tform2
哪位指点指点啊
登录成功以后要运行unit2里的form2
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
unit2,Dialogs, StdCtrls, DB, ADODB;type
TForm1 = class(TForm) Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
DataSource1: TDataSource;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject); var
LoginCount: Integer;
begin LoginCount := 0;
with ADOQuery1 do
begin
Close;sql.Add('select * from users where id=:username');
parameters.ParamByName('username').Value :=trim(Edit1.Text );
open;
end;
if ADOQuery1.FieldByName('pwd').AsString =trim(Edit2.Text ) then
begin
Form1.Hide ; Tform2.Show;application.MessageBox('成功!','系统提示',0+64);end
else
begin
application.MessageBox('密码或者用户名错误,请确认!','系统提示',0+64);end;
end;end.
但是 Tform2.Show; 这句报错 意思是找不到tform2
哪位指点指点啊
……
……
……
uses unit2;
……
……
form2:=Tform2.create(nil);
try
form2.showmodal;
finally
from2.free;
from2:=nil;
end;……
……
……
你要具体实例化一个Tform2的对象