Private Sub Form_Load()    Dim Dept As cDept
    Dim Depts As cDepts
    
    Set Depts = New cDepts
    For Each Dept In Depts
    Next DeptEnd Subcdept 为一对像 
cdepts 为cdept对像的集合,为什么执行到 For Each Dept In Depts
会出现 "Object doesn't support this property or method
"错误

解决方案 »

  1.   

    在Depts类中写个这样的属性
    Public Property Get NewEnum() As IUnknown
       '本属性允许用 For...Each 语法枚举该集合。
       Set NewEnum = m_Col.[_NewEnum]
    End Property
    这个m_Col是指Depts类中用来表示Dept的集合[数组]
    过程的属性为Attribute NewEnum.VB_UserMemId = -4
      

  2.   

    我的意思是cDept 为部门类cDepts 为部门的集合类
      

  3.   

    Dim Depts As Collection
    set Depts = 集合(Collection类型)
      

  4.   

    是不是与forms或controls一样的意思啊??
      

  5.   

    找到原因了,原来过程的属性为Attribute NewEnum.VB_UserMemId = -4没设置