想请问一下在Delphi中自已写一个函数或过程,要让其中的一个参数变为不必选的,应该如可写呢?
在VB中可以用optional这个关键字来声明,不知道在Delphi中应该如何做?

解决方案 »

  1.   

    在DELPHI 中可以这样写:procedure GetQueryResult ( SQLStr:String , bAdd : Boolean = true);如果不指定bAdd的值,则默认为trueexample:private
        procedure GetQueryResult ( SQLStr:String ; bAdd : Boolean = true);
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    begin
       getqueryresult('qdkf');
    end;procedure TForm1.GetQueryResult(SQLStr: String; bAdd : Boolean = true);
    begin
      showmessage('SQLStr');
    end;