【问题标题】:Whats wrong? (Type of expression must be BOOLEAN)怎么了? (表达式的类型必须是 BOOLEAN)
【发布时间】:2013-01-14 15:56:48
【问题描述】:

我的代码有什么问题?我收到此错误:

[dcc32 Error] Unit6.pas(83): E2012 Type of expression must be BOOLEAN

function checkver(): boolean;
begin
  //some code here
end;

function refresh(): boolean;
begin
  //some code here
end;

procedure TForm6.FormCreate(Sender: TObject);
begin
  if checkver() then
    if refresh() then  //Error is HERE!!
      //some code here
end;

(full code)

【问题讨论】:

  • 也许您应该考虑重命名该过程。也许让它成为类的方法。

标签: delphi function boolean


【解决方案1】:

TControl(你的表单类的后代)有a Refresh method of its own,它不返回布尔值。该方法的范围比同名的单元级方法的范围更近,因为您在该类的方法中编写代码,因此编译器与Refresh 方法绑定,而不是refresh 函数.

调用<unitname>.refresh获取单元级函数而不是方法。

【讨论】:

  • 非常感谢,我没想到回复这么快)
猜你喜欢
  • 2021-06-16
  • 1970-01-01
  • 2011-09-26
  • 2015-07-07
  • 2023-03-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多