gpt4 book ai didi

delphi - 这种形式的方法调用仅允许类方法错误

转载 作者:行者123 更新时间:2023-12-03 14:57:07 25 4
gpt4 key购买 nike

我不断收到此错误。在 FGetZoneData 上我有:

var
SelectedDept: String;

implementation

procedure TFGetZoneDept.GetClick1(Sender: TObject);
var
azone: string;
adept: string;
bstats,
bname,
btop,
bleft,
bnumber,
basset: string;
machine : TMachine;
begin
fdb.count := 0; //keeps track of number of machines in zone
azone := Combobox1.Text; //gets name of zone
adept := TfDB.GetDeptDBName(SelectedDept); //gets name of dept from a function
fdeptlayout.ListBox1.Clear;
end;

TFdB 上,我有一个公开声明的函数:

public
Function GetDeptDBName(name :string):String;
end;

知道为什么这行不通吗?

最佳答案

您正在类(我假设 TfDB 是类名)而不是实例上调用该方法。仅class methods可以这样称呼。您要做的就是创建一个实例,然后调用它的方法:

var DB: TfDB;
begin
DB := TfDB.Create(); // create an instance
adept := DB.GetDeptDBName(SelectedDept); // call the method

请参阅E2076 This form of method call only allowed for class methods docwiki 中的主题。

关于delphi - 这种形式的方法调用仅允许类方法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14770299/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com