读书人

能否帮小弟我找错呢各位大侠

发布时间: 2012-03-23 12:06:21 作者: rapoo

能否帮我找错呢,各位大侠
下面是我的代码,为什么我加了屏蔽的那一行运行是直接就退出了呢
procedure TForm1.Button1Click(Sender: TObject);
begin
if combobox1.text='' then
begin
showmessage('用户名不能为空');
exit;
end;
if edit2.Text='' then
begin
showmessage('密码不能为空');
exit;
end;
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select * from 用户表 where 用户名='''+combobox1.text+''' and 密码='''+edit2.Text+'''');
open;
if adoquery1.RecordCount<>0 then
begin
form2.show;
// form1.Close;
end
else
begin
showmessage('用户名或密码不正确,请重新输入');
exit;
end;
end;
end;

[解决办法]
你的FORM1是主窗体吧,form1.Close;要改成form1.Visible := false;或者form1.Hide;

Delphi(Pascal) code
begin  Application.Initialize;  Application.CreateForm(TForm1, Form1);//第一个为主窗体  Application.CreateForm(TForm2, Form2);  Application.Run;end.
[解决办法]
C# code
try{   form1.Close;}catcha(Excepting ex){   message.show(ex.tostring() );} 

读书人网 >.NET

热点推荐