procedure sfbitian(t:Tform;sfbitian:Tadoquery);
var i:integer;
begin
sfbitian.Close;
sfbitian.SQL.Clear;
sfbitian.sql.Add('select * from kysys_biaotou  where sfbitian=''是''');
sfbitian.Open;
while not sfbitian.Eof do
begin
 for i:=0 to t.ComponentCount-1 do
  begin
   if t.components[i] is Trzedit then
   begin
   if Trzedit(t.Components[i]).name=sfbitian.FieldValues['kjname'] then
     begin
      if Trzedit(t.Components[i]).Text='' then
      begin
      showmessage(sfbitian.FieldValues['kjcaption'] + '不能为空');
      exit;
      end;
     end;
   end;
  end;
  sfbitian.Next;
 end;
请问各位大侠,我如何能在showmessage后退出,并不执行下面的代码?我这段代码后还有一个函数。
procedure Tfsxht.bcClick(Sender: TObject);
begin
sfbitian(fsxht,bitianxiang);
save(fsxht);
end;

解决方案 »

  1.   

    把procedure改成function,设置一个返回值,比如boolean类型,然后:
    if sfbitian(fsxht,bitianxiang) save(fsxht);
      

  2.   

    把procedure sfbitian 改成function sfbitian ;根据返回值决定后面是否继续执行要不就把exit改成abort;
      

  3.   

    对,改成function返回bool值,进行判断
      

  4.   

    跳出当前循环continue,跳出循环break,结束exit
      

  5.   

    procedure 修改成function ,然后设置result,再exit
    接着根据返回值判断不执行下个函数就行了
      

  6.   

    //在var的前面定义一个label
    label
      out_loop;
    var
    ...
    begin
      ...//把out_loop放到你要showmessage后跳出到的地方
    out_loop:
      bcClick(nil);//然后在你的showmessage后面加上:
      goto  out_loop;
      
      

  7.   

    就是把procedure 改成 function就行了,加一个返回值,这是最基本也是最正统的写法吧!至于goto这个东西,谁在程序里还用它?