读书人

result从哪里冒出来的?该如何解决

发布时间: 2012-03-08 13:30:13 作者: rapoo

result从哪里冒出来的?
书上的一个例题函数是这样的

Delphi(Pascal) code
function TDragForm.AddNotDup (List: TCustomListBox; Text: string): Boolean;begin   // 判断项目是否存在  Result := List.Items.IndexOf (Text) < 0;  if Result then    List.Items.Add (Text);end;


从函数中能看出来这个result应该是返回的值

但是在我照着写的时候确报错
function tdragform.addnotdup(list:TCustomListBox;text:string):Boolean;
begin
Result:=list.
end;写到这里报错
[Pascal Error] Unit1.pas(1): Unable to invoke Code Completion due to errors in source code

我想问书上的例题这个Result是从哪里出来的

[解决办法]
探讨
书上的一个例题函数是这样的

Delphi(Pascal) code
function TDragForm.AddNotDup (List: TCustomListBox; Text: string): Boolean;
begin
// 判断项目是否存在
Result := List.Items.IndexOf (Text) < 0;
if Result then
……

读书人网 >.NET

热点推荐