Function GetADNList(ByVal strSql As String) As ??
Dim myADNList As DataList
Dim myNode As Node
Set myADNList = New DataList
With cmd
    .CommandText = strSql
    .CommandType = adCmdText
End With
                    
cmd.Execute
rs.Open cmd, , adOpenStatic, adLockOptimistic
                    
While Not rs.EOF
    Set myNode = New Node
    With myNode
        .ADN_ID = rs("adn_index")
        .ADN_NAME = rs("user_name")
        .ADN_PHONEBOOK = rs("phonebook_index")
        .ADN_GROUPS = rs("group_index")
    End With
    
    myADNList.AddNode myNode
    
    rs.MoveNext
Wendrs.Close 'GetADNList = myADNList
End Function
问题1:怎样才能把MYADNLIST作为函数的结果传出去
问题2:GetADNList的返回类型是什么,让我返回自定义的类请大虾们帮忙看看,非常感谢!

解决方案 »

  1.   

    Function GetADNList(ByVal strSql As String) As DataList
    .................
    set GetADNList=myADNList 
    End Function
      

  2.   

    是你自己的定义的? 放在 module 里面,
    public type DataList
      

  3.   

    Function GetADNList(ByVal strSql As String) As DataList
    Dim myADNList As DataList
    Dim myNode As Node
    Set myADNList = New DataList
    With cmd
        .CommandText = strSql
        .CommandType = adCmdText
    End With
                        
    cmd.Execute
    rs.Open cmd, , adOpenStatic, adLockOptimistic
                        
    While Not rs.EOF
        Set myNode = New Node
        With myNode
            .ADN_ID = rs("adn_index")
            .ADN_NAME = rs("user_name")
            .ADN_PHONEBOOK = rs("phonebook_index")
            .ADN_GROUPS = rs("group_index")
        End With
        
        myADNList.AddNode myNode
        
        rs.MoveNext
    Wendrs.Closeset GetADNList = myADNList
    End Function
      

  4.   

    compile error:
        Private object modules cannot be used in public object modules as parameters or return types for public procedures,as public data members,or as fields of public user defined types
      

  5.   

    DATALIST是类模块的名字,这个类模块里是一些方法
      

  6.   

    不要将DATALIST定义成type,而是定义成一个类,建立类模块。