Results 1 to 14 of 14

Thread: Returning Properties Values

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2003
    Location
    The Future - Skynet
    Posts
    1,157

    Returning Properties Values

    Is there a way to return the value for each of the property for an object?

    Similar to this but on the same level as the Properties such as Connection and ConnectionString:
    Code:
        Dim adoProp As ADODB.Property
        For Each adoProp In adoConn.Properties
        Next
    http://www.vbforums.com/showthread.p...ate+properties
    Last edited by Liquid Metal; Jun 11th, 2008 at 04:37 PM.
    I'll Be Back!

    T-1000

    Microsoft .Net 2005
    Microsoft Visual Basic 6
    Prefer using API

  2. #2
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Returning Properties Values

    I believe someone named Westconn1 or something posted code for this awhile back. I don't know if he used the TypeLibrary Information "TLBINF32.DLL" or something like that to do it. But if you can find his name you may be able to find the post, or maybe PM him. Hopefully I am remembering correct and it wasn't someone else that posted it.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2003
    Location
    The Future - Skynet
    Posts
    1,157

    Re: Returning Properties Values

    Thank for the info DigiRev! I will look into WestConn's post.

    I did find this:
    http://www.vbforums.com/showthread.p...ate+properties
    I'll Be Back!

    T-1000

    Microsoft .Net 2005
    Microsoft Visual Basic 6
    Prefer using API

  4. #4
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Returning Properties Values

    Hm, I don't think that is the one. That is back from 2001, and I'm still pretty sure it was westconn1 that posted it, and I don't remember it being too long ago but wasn't very recently either.

    But does the code in that thread do what you want?

    I would send him a PM and apologize for me in advance if he is indeed not the one that posted it.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2003
    Location
    The Future - Skynet
    Posts
    1,157

    Re: Returning Properties Values

    I did a search with "TLBINF32.DLL" and "WestConn" (as well as "WestConn1") but nothing popped up.

    I did do another search with "TLBINF32" only and only 5 posts popped up.
    I'll Be Back!

    T-1000

    Microsoft .Net 2005
    Microsoft Visual Basic 6
    Prefer using API

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Returning Properties Values

    I had something about TypeLibs bookmarked, and it may be what you were thinking of:
    http://www.vbforums.com/showthread.php?p=2977810

    With some modifications, the code in post #2 should do the trick I think.

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2003
    Location
    The Future - Skynet
    Posts
    1,157

    Re: Returning Properties Values

    Hi Si_The_Great!

    The code does not seem to return the value of the property but will test it out tonight when I get to my home computer with VB6.

    Thank You
    I'll Be Back!

    T-1000

    Microsoft .Net 2005
    Microsoft Visual Basic 6
    Prefer using API

  8. #8
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Returning Properties Values

    It won't work as-is, but should be fairly close.. I suspect that member will have several properties in addition to the name, including a value (and data type info, etc).

  9. #9
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Returning Properties Values

    What you need to do is using CallByName with each Member Name

  10. #10
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Returning Properties Values

    Searching from si's link, I also found this, not sure if you came across it or not:

    http://www.vbforums.com/showthread.php?t=476509

  11. #11

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2003
    Location
    The Future - Skynet
    Posts
    1,157

    Re: Returning Properties Values

    I am going to test this out tonight and will let you all know the progress. Thanks and remember to check back to this thread.
    I'll Be Back!

    T-1000

    Microsoft .Net 2005
    Microsoft Visual Basic 6
    Prefer using API

  12. #12
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Returning Properties Values

    OK, here it is, it's really easy when properties are string, numbers.. but things get more complicated when objects are returned, because you need to assign that to another Object, and sometimes arrays, collections or empty objects are returned and you need different code according to that, so manage returned values according to your objects, using a Form as parameter it works with this code, but it would also depend and what Controls are present in the Form. lMembers.ReturnType gives you the type of whatever is returning, it's a TliVarType, if you right click one of these, like VT_BSTR and click definition, you'll see the complete list. Add a ListBox to your Form.
    Code:
    Private Sub GetMembers(pList As ListBox, pObject As Object)
    Dim TLI         As TLIApplication
    Dim lInterface  As InterfaceInfo
    Dim lMember     As MemberInfo
    Dim lObjRet     As Object
    Dim lStrRet     As String
    Dim lRetType    As TliVarType
    
        Set TLI = New TLIApplication
        Set lInterface = TLI.InterfaceInfoFromObject(pObject)
        
        For Each lMember In lInterface.Members
            If lMember.InvokeKind = INVOKE_PROPERTYGET Then
                lRetType = lMember.ReturnType
                Select Case lRetType
                    Case VT_DISPATCH
                        Set lObjRet = CallByName(pObject, lMember.Name, VbGet, 0)
                        pList.AddItem lMember.Name & " = " & lObjRet
                    Case VT_EMPTY 
                        'You should do nothing here, but doing the following you will see the same than the 
                        'Prop window shows in VB, sometimes it's a  a number, like in props Picture, Image, Font, Icon...
                         Set lObjRet = CallByName(pObject, lMember.Name, VbGet)
                         If Not (lObjRet Is Nothing) Then pList.AddItem lMember.Name & " = " & lObjRet
                    Case Else  '(VT_BSTR = String, VT_BOOL  = Boolean,VT_DATE, VT_DECIMAL, VT_VARIANT..etc)
                         lStrRet = CallByName(pObject, lMember.Name, VbGet)
                         pList.AddItem lMember.Name & " = " & lStrRet
                End Select
                
            End If
        Next
        
        Set pObject = Nothing
        Set lInterface = Nothing
        Set TLI = Nothing
    End Sub
    
    
    Private Sub Form_Load()
        GetMembers List1, Me
    End Sub
    EDIT: I forgot, add a reference to "TLBINF32.DLL" it's in C:\Windows\System32
    Last edited by jcis; Jun 11th, 2008 at 07:18 PM.

  13. #13

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2003
    Location
    The Future - Skynet
    Posts
    1,157

    Re: Returning Properties Values

    Thank You so much JCIS. I will validate tonight.
    I'll Be Back!

    T-1000

    Microsoft .Net 2005
    Microsoft Visual Basic 6
    Prefer using API

  14. #14

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2003
    Location
    The Future - Skynet
    Posts
    1,157

    Re: Returning Properties Values

    JCIS, that is pretty much what i am looking for. Too bad it does not do recursive to look for such as "Properties" and so on. I will look into this but thank you for getting me started with the code that you supplied.

    I also want to say thank you to everyone else too. Will make my life much easier to test properties out.
    I'll Be Back!

    T-1000

    Microsoft .Net 2005
    Microsoft Visual Basic 6
    Prefer using API

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width