//***************************************************//
procedure TForm1.GetSearchField:string;
var
  Result:string;
begin
  Result := adodataset1.fields[rgfieldnames.itemindex].fieldname;
end;
//***************************************************//这是书上写到的,可是我输入delphi,显示
[Error] Unit1.pas(40): Procedure cannot have a result type
那书上是怎么通过的?
还有书上并没有Result这个变量,var那里是我加上去的,系统中有没有内建这个result
参考书目:Delphi 5.X ADO_MTS_COM+高级程序设计篇
第二章 76页处

解决方案 »

  1.   

    function TForm1.GetSearchField:string;
    begin
      Result := adodataset1.fields[rgfieldnames.itemindex].fieldname;
    end;
      

  2.   

    var
      Result1:string;
    begin
      Result1 := adodataset1.fields[rgfieldnames.itemindex].fieldname;
    end;
    //Result是Pascal的保留字,用于返回Function的结果的
      

  3.   

    haha, can a procedure has return value?
      

  4.   

    HEHE ,修改结果
    procedure TForm1.GetSearchField;
    var
      Result:string;
    begin
      Result := adodataset1.fields[rgfieldnames.itemindex].fieldname;
    end;
    或者
    function TForm1.GetSearchField:string;
    begin
      Result := adodataset1.fields[rgfieldnames.itemindex].fieldname;
    end;