unit1调用unit2的函数出错--------在线等候(50分)

  • 主题发起人 YuanGuo2001
  • 开始时间
Y

YuanGuo2001

Unregistered / Unconfirmed
GUEST, unregistred user!
大家帮忙看一下,为什么unit1调用unit2出错??

unit1

implementation

{$R *.dfm}
uses unit2



而unit 2 的代码为

unit unit2;

interface

function GetValue(Var AValue:TStrings):Boolean;//%%%%%%%%%%%%%%%%%%%%%%%标志
implementation
uses Classes, SysUtils, Controls, Windows, Registry, Forms, ComCtrls, CommCtrl,
Messages, FileCtrl,unit1;




function GetValue( AValue:tStrings):Boolean;
begin
end;

上面的行%%%%%%%%%%%%%%%%%%%%%%%标志
为什么会提示 "Undeclared identifier:'tStrings'"
 
因为你的定义在uses之前,这个时候编译器认为还没有定义tstring这个类,如果你定义在uses
之后,就不会出现这个错误了。
 
Unit2中有错误。
改为:
unit unit2;
interface
uses Classes, SysUtils, Controls, Windows, Registry, Forms, ComCtrls, CommCtrl,
Messages, FileCtrl;

........

function GetValue(Var AValue:TStrings):Boolean;//%%%%%%%%%%%%%%%%%%%%%%%

implementation
uses unit1;

{$R *.dfm}

function GetValue( AValue:tStrings):Boolean;
begin
end;

 
将声明放在 uses 后面。!!!!
 
将你自定义的function GetValue( AValue:tStrings):Boolean;放在USES的后面。
 
unit unit2;
//添加:
uses Classes;
interface
 
同意楼上的,补全:
unit unit2;

interface
uses
Classes;
function GetValue(Var AValue:TStrings):Boolean;//%%%%%%%%%%%%%%%%%%%%%%%标志

implementation
uses SysUtils, Controls, Windows, Registry, Forms, ComCtrls, CommCtrl,
Messages, FileCtrl,unit1;
function GetValue( AValue:tStrings):Boolean;
begin
end;
 
Block_K_E的解释正确,也感谢其他dfw.
 
顶部