两个Unit如下:
unit1
...
TForm1 = class(TForm)
...
  public
    procedure M1(arg1:string);
end;implementation
  uses unit2;
...unit2
...
TForm2 = class(TForm)
  private
    procedure M2;
end;
implementation
  uses unit1;
..在unit2中M2方法中如何调用unit1,Form1中的M1方法?
我是这样写的:
Form1.M1(arg);
为什么会出错???不解啊!

解决方案 »

  1.   

    是不是Form1没有创建,所以不能调用的原因.
      

  2.   

    把你的程序发给我看看,
    [email protected]
      

  3.   

    form1没有create就会出现访问地址信息出错
    把form1的函数定义在implementation上面再试试
      

  4.   

    不可能啊!Form1是程序的主窗口,一开始就创建了.
      

  5.   

    不可能啊!Form1是程序的主窗口,一开始就创建了.
      

  6.   

    不可能啊!Form1是程序的主窗口,一开始就创建了.
      

  7.   

    你只是在FORM1中USES UNIT2了,但是你实际上是在UNIT2中调用UNIT1中实例的方法。你有么有在UNIT2中写上USES UNIT1呢?
      

  8.   

    我写了!两个单元都在implementation段写了互相引用.
      

  9.   

    如果是单纯的CLASS 单元 没有控件  就直接使用Form1.M1(arg);sm cuowu>
      

  10.   

    Project FilePacker.exe raised exception class EAccessViolation with message 'Access violation at address 0043c9f8
    in module 'FilePacker.exe'.Read of address 00000005'.Process stopped.Use Step or Run to continue.
      

  11.   

    你在 uses 单元中,把unit1 加上
      

  12.   

    把其中的一个
    uses unit1;   (或uses unit2;)
    放到interface下面,两个都放到
    implementation下要出错
      

  13.   

    没有建类,不能调用。
    用继承吧Form2 = class(TForm1)
      

  14.   

    USES UNIT1 ;
    并且该方法是PUBLIC或PUBLISHED的.