if(process_no.Text <> '') and (winprg.Text <> '') then
begin
try
with DM.qryMenzheng do
begin
Close;
SQL.Clear;
SQL.Add(str);
SQL.Add(' where a.process_no =' +process_no.Text);
SQL.Add(' AND a.winprg =' + winprg.Text);
SQL.Add(' order by a.patient_no');
Open;
{*******Add by ice 2003-7-26 begin*******}
if (DM.qryMenzheng.RecordCount < 1 ) then
ShowMessage('对不起,没有找到您所要信息,请检查您输入的号码是否正确!');
process_no.Text := '';
process_no.SetFocus;
Screen.Cursor := crDefault;
exit;
{*******Add by ice 2003-7-26 end ******* }
for i:= 0 to dbgMenZheng.Columns.Count - 1 do
begin
dbgMenZheng.Columns[i].Width := 80;
end;
end;
except
Application.MessageBox('读取数据库时失败', '错误', MB_ICONSTOP);
end;
Screen.Cursor := crDefault;
end
else
begin
ShowMessage('请输入要查询的发票流水号和站号');
if(process_no.Text = '') then
process_no.SetFocus
else
winprg.SetFocus;
Exit;
end;提示错误: if和else不匹配
begin
try
with DM.qryMenzheng do
begin
Close;
SQL.Clear;
SQL.Add(str);
SQL.Add(' where a.process_no =' +process_no.Text);
SQL.Add(' AND a.winprg =' + winprg.Text);
SQL.Add(' order by a.patient_no');
Open;
{*******Add by ice 2003-7-26 begin*******}
if (DM.qryMenzheng.RecordCount < 1 ) then
ShowMessage('对不起,没有找到您所要信息,请检查您输入的号码是否正确!');
process_no.Text := '';
process_no.SetFocus;
Screen.Cursor := crDefault;
exit;
{*******Add by ice 2003-7-26 end ******* }
for i:= 0 to dbgMenZheng.Columns.Count - 1 do
begin
dbgMenZheng.Columns[i].Width := 80;
end;
end;
except
Application.MessageBox('读取数据库时失败', '错误', MB_ICONSTOP);
end;
Screen.Cursor := crDefault;
end
else
begin
ShowMessage('请输入要查询的发票流水号和站号');
if(process_no.Text = '') then
process_no.SetFocus
else
winprg.SetFocus;
Exit;
end;提示错误: if和else不匹配
解决方案 »
- 用Tchromium替代webbrowser提交网页表单问题
- 如何支持多国语言
- ◆我的疑惑:请问哪个比较节省资源,存储速度比较快??
- 开机启动程序问题
- 提问!提问!可不可以在memo中显示.txt文档其中一行的内容啊?可以的话,咋弄呢?
- ADOQuery连接的数据源,如何刷新?
- 把EXCEL文件导入到ORACLE数据库表中,和把ORACLE数据库表中的数据导入到EXCEL文件中
- 请教 下 在 windows Vista/Win 7 下如何读取 BIOS 的内容?
- 想学地理信息系统,说搞过GIS?给个源程序学学好吗?
- 大小写转化,在输入汉字时出现的问题比如……,再线等待……
- 如何控制鼠标移动
- 为什么会出现编译错误?
begin //////////这里
ShowMessage('对不起,没有找到您所要信息,请检查您输入的号码是否正确!');
process_no.Text := '';
process_no.SetFocus;
Screen.Cursor := crDefault;
exit;
{*******Add by ice 2003-7-26 end ******* }
for i:= 0 to dbgMenZheng.Columns.Count - 1 do
begin
dbgMenZheng.Columns[i].Width := 80;
end;
end;
单从这段程序代码来看,IF/ELSE是配套的,
如果在if (DM.qryMenzheng.RecordCount < 1 ) then的后面加上BEGIN,那么WTITH的END就没有了。
但我认为你的程序从逻辑上说不过去,你应该看下程序的其他位置。
begin
try
with DM.qryMenzheng do
begin
Close;
SQL.Clear;
SQL.Add(str);
SQL.Add(' where a.process_no =' +process_no.Text);
SQL.Add(' AND a.winprg =' + winprg.Text);
SQL.Add(' order by a.patient_no');
Open;
{*******Add by ice 2003-7-26 begin*******}
if (DM.qryMenzheng.RecordCount < 1 ) then
begin
ShowMessage('对不起,没有找到您所要信息,请检查您输入的号码是否正确!');
process_no.Text := '';
process_no.SetFocus;
Screen.Cursor := crDefault;
exit;
{*******Add by ice 2003-7-26 end ******* }
for i:= 0 to dbgMenZheng.Columns.Count - 1 do
begin
dbgMenZheng.Columns[i].Width := 80;
end;
end;
end;
except
Application.MessageBox('读取数据库时失败', '错误', MB_ICONSTOP);
end;
Screen.Cursor := crDefault;
end
else
begin
ShowMessage('请输入要查询的发票流水号和站号');
if(process_no.Text = '') then
process_no.SetFocus
else
winprg.SetFocus;
Exit;
end;
for i:= 0 to dbgMenZheng.Columns.Count - 1 do
begin
dbgMenZheng.Columns[i].Width := 80;
end;
又有什么意义????他的前面已经Exit了,唉,好像楼主的函数没有说明白,怎么看起来逻辑有问题
这样做肯定不会出现这样的问题
begin
dbgMenZheng.Columns[i].Width := 80;
end;可以写成,少一个让你眼花的beginfor i:= 0 to dbgMenZheng.Columns.Count - 1 do
dbgMenZheng.Columns[i].Width := 80;
由于 PASCAL 语言中所有语句的结束都是用 END,对于程序阅读有一定困难
建议这样if Exp1 = Exp2 then
begin
ShowMessage('1');
end else begin
with Form1 do
begin
ShowMessage('1');
end; // with Form1 do
end; // if Exp1 = Exp2
if (DM.qryMenzheng.RecordCount < 1 ) then //这里少了一个"Begin" ShowMessage('对不起,没有找到您所要信息,请检查您输入的号码是否正确!');
process_no.Text := '';
process_no.SetFocus;
Screen.Cursor := crDefault;
exit;
{*******Add by ice 2003-7-26 end ******* }
for i:= 0 to dbgMenZheng.Columns.Count - 1 do
begin
dbgMenZheng.Columns[i].Width := 80;
end;
end;
我觉的逻辑上有错误,再根据你的程序实现的功能来检查检查
尽可能的减少这种套接的写法