求助!在自己写的函数单元中调用self,提示未声明的标示符usesWindows, Messages, SysUtils, Classes, Graphics, Controls, Forms, DB, ADOdb, Dialogs,
    M_DataModule, StdCtrls, ComCtrls, Variants, ExtCtrls;
...
var d:tquery;
...
d:=d.create(self);
...编译时提示self未声明,不解
请高手赐教

解决方案 »

  1.   

    self 只有在類範圍內使用.>>>>>>>>>>>>>>
    var d:tquery;
    ...
    d:=d.create(self);   <<<<在單元內不能這樣使用!
    ...
      

  2.   

    d:=d.create(nil);self应该是类..必须包括在type里面.
      

  3.   

    Within the implementation of a method, the identifier Self references the object in which the method is called. For example, here is the implementation of TCollection's Add method in the Classes unit.
    var d:tquery;
    ...
    d:=d.create(nil);   <<改為nil...
      

  4.   

    我把self改成nil了报错,内存错误
      

  5.   

    在单元你不能用self
    你最好是传个类到参数中
      

  6.   

    d:=d.create(TQuery);
    这样可以吗?
    我记得我以前就是这样的
      

  7.   

    晕,差点被你绕进去应该这样写:d:=TQuery.Create(self);
      

  8.   

    d:=d.create(self);

    d:=TQuery.create(self);吧
      

  9.   

    低级错误,抱歉各位:D应该是
    d:=Tquery.create(nil);这样调用成功如果用self应该是把它放在自己定义的一个类里就能用了