Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: VB5,VB6
Expertise: Beginner
Aug 26, 2000



Building the Right Environment to Support AI, Machine Learning and Deep Learning

GetClassesByMember - Retrieve the list of classes that expose a given property or method

' return a collection with names of all the class names
' of a type library that implement a certain member.
' MEMBERNAME is the name of the property or method
' MEMBERTYPE is the type of the member (vbGet, vbLet, vbSet, vbMethod).
'    You can specify multiple types by ORing these constants 
' Example:
'     Dim tlb As String
'     Dim retColl As Collection
'     tlb = "C:\MyServer.Dll"
'     ' returns all types with MyProp (Let, Set or Get) property 
'     Set retColl = GetClassesByMember(tlb, "MyProp", VbLet Or VbSet Or VbGet)
'     ' returns all types with MyProp Let property
'     Set retColl = GetClassesByMember(tlb, "MyProp", VbLet)
'     ' returns all types with MyFunc function (or Sub)
'     Set retColl = GetClassesByMember(tlb, "MyFunc", VbMethod)

' Be sure that "TypeLib Information" type library (TlbInf32.tlb)
' is referenced in your VB project.

Function GetClassesByMember(ByVal TypeLibFile As String, _
    ByVal MemberName As String, MemberType As VbCallType) As Collection
    Dim TLI As New TLIApplication
    Dim TypeLibrary As TypeLibInfo
    Dim TypeInfo As TypeInfo
    Dim Results As SearchResults
    Dim Item As SearchItem
    ' raises an error if unable to open the type library
    ' (e.g. file not found or not a TLB)
    Set TypeLibrary = TLI.TypeLibInfoFromFile(TypeLibFile)

    ' prepare the result
    Set GetClassesByMember = New Collection

    ' search types containing the requested member
    Set Results = TypeLibrary.GetTypesWithMemberEx(MemberName, MemberType, , _
    ' fill the return collection with found type names
    For Each Item In Results
        GetClassesByMember.Add Item.Name, Item.Name
End Function

Alberto Falossi
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date