试试带参数的 Exit

试试带参数的 Exit

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function fun(str: string): string;
begin
  if str = '' then Exit('空'); {Delphi 2009 支持}
  Result := str + str;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  s: string;
begin
  s := fun('ABC');
  ShowMessage(s);  {ABCABC}

  s := fun('');
  ShowMessage(s);  {空}
end;

end.
posted on 2008-08-12 23:47  万一  阅读(3782)  评论(6)  编辑  收藏
上一篇:return和exit


下一篇:C#开发WinForm窗体程序时,如何在子窗体中关闭窗口时并退出程序?(转)