我自定义类型:      Type myData
         t as string
         i as integer
      end type      sub test()
          dim d as myData
          dim c as new collection
          c.add d
      end sub
   
  执行以上test()过程将提示出错,或者将自定义类型当参数传递也出现同样的错误提示,如下:
      Type myData
         t as string
         i as integer
      end type      sub test()
          dim d as myData
          call test1(d)
      end sub
      sub test1(tt as myData)       
          ...
      end sub  请问VB6能否传递自定义类型,如果能,如何传递?

解决方案 »

  1.   

    如果你上面的代码放在标准模块中,你会发现,它是正确的
    如果不是放在标准模块中,声明改为这样:      Private Type myData
             t as string
             i as integer
          end type      sub test()
              dim d as myData
              call test1(d)
          end sub
          Private  sub test1(tt as myData)       
              ...
          end sub
      

  2.   

    我自定义类型:      Type myData
             t as string
             i as integer
          end type      sub test()
              dim d as myData
              dim c as new collection
              c.add d
          end sub
    ------------------------------------------------
    上面的往集合里添加成员的代码有错误,不能往集合添加结构体类型数据:dim d as myData
    dim c as new collectionc.add d  '错误写法
    c.add d.t  '正确写法
    c.add d.i  '正确写法
      

  3.   

    faysky2()兄你的说法很正确.
    必须指定自定义类型中的某一个变量,而且必须注意数据类型.