我想在自己实现的类中使用自定义的数据类型做属性返回。或是做类共有函数的参数及返回值。
可VB6为什么老报:only public user defined types defined in public object modules
can be used as parameters or return types for public procedures of class modules 
or as field of public user defined types我都要晕了明明在数据模块我定义了共有数据类型:
Public Type CoordinatePoint
    X As Double
    Y As Double
End Type可还会有上面的错误报告呀!

解决方案 »

  1.   

    Private Type CoordinatePoint
        X As Double
        Y As Double
    End Type
      

  2.   

    可以把结构体先放到一个二进制数组里,传出去以后接受方再从二进制数组复制到结构体.
    比如Private type PointAPI
            X as long:Y as long
    End type定义结构体
    dim Struct as PointAPI
    赋值
    Struct.X=100
    Struct.Y=200复制到数组
    dim Buffer() as byte
    redim Buffer(len(Struct))
    'Copymemory是API函数,要先定义[声明可以在VB的API浏览器里找到]
    Copymemory byval varptr(buffer(0)),byval varptr(Struct),len(Struct)定义函数
    public function Test(byref Bytes() as byte)
    end function如果要还原还结构体
    CopyMemory byval varptr(Struct),byval varptr(buffer(0)),len(Struct)