Here's a modification which works without Error-Handling.
Code:
Option Explicit
Private Sub Form_Load()
EnumerateProperties Text1, INVOKE_PROPERTYGET
EnumerateProperties Text1, INVOKE_PROPERTYPUT
End Sub
Public Function EnumerateProperties(pObject As Object, pType As InvokeKinds)
Dim TypeLib As TLI.InterfaceInfo, Prop As TLI.MemberInfo, Ret
Set TypeLib = TLI.InterfaceInfoFromObject(pObject)
For Each Prop In TypeLib.Members
If Prop.InvokeKind = pType And Prop.Name <> "Index" Then
AssignVariantValue Ret, TLI.InvokeHook(pObject, Prop.MemberId, INVOKE_PROPERTYGET)
Debug.Print Left$(Prop.Name & Space$(25), 25); TypeName(Ret), IIf(IsObject(Ret), "<ObjRef>", Ret)
End If
Next
End Function
Private Sub AssignVariantValue(Dst, Src)
If IsObject(Src) Then Set Dst = Src Else Dst = Src
End Sub
And Prop.Name <> "Parent" _
And Prop.Name <> "Container" _
And Prop.Name <> "DataSource" _
And Prop.Name <> "DataFormat")
I'm curious why but I'm marking this resolved.
But other than that read and write properties both list now.
Thanks to everyone that responded! I'm going to attach the final code in case someone searches on this.
You need to add a component for a listview and a listview named ListView1 (Microsoft windows common controls 6.0)
Set a project reference to the TypeLib Information library
Two option buttons (optReadOnly and OptWritable)
A command button cmdGo
A textbox Text1
There is logic to sort by clicking on the listview column header.
I'm done playing with it. My coworker got his answer from the writable logic.
Thanks again all!
Code:
Option Explicit
'Modified from http://www.vb-helper.com/howto_get_property_information.html
'Set a project reference to the TypeLib Information library
Public Function EnumerateProperties(pObject As Object, pType As InvokeKinds)
Dim TypeLib As TLI.InterfaceInfo, Prop As TLI.MemberInfo, Ret
Dim templist As ListItem
Set TypeLib = TLI.InterfaceInfoFromObject(pObject)
ListView1.ListItems.Clear
For Each Prop In TypeLib.Members
If Prop.InvokeKind = pType And (Prop.Name <> "Index" _
And Prop.Name <> "Parent" _
And Prop.Name <> "Container" _
And Prop.Name <> "DataSource" _
And Prop.Name <> "DataFormat") Then
AssignVariantValue Ret, TLI.InvokeHook(pObject, Prop.MemberId, INVOKE_PROPERTYGET)
Set templist = Me.ListView1.ListItems.Add
templist.ListSubItems.Add , , (CStr(Prop.Name))
templist.ListSubItems.Add , , (Left$(TypeName(Ret) & Space$(10), 10))
templist.ListSubItems.Add , , (Ret)
End If
Next
End Function
Private Sub AssignVariantValue(Dst, Src)
If IsObject(Src) Then Set Dst = Src Else Dst = Src
End Sub
Private Sub cmdGo_Click()
If optReadOnly.Value = True Then
EnumerateProperties Text1, INVOKE_PROPERTYGET
Else
'Note the index is provided below. A loop would be needed to go through an array.
EnumerateProperties Text1, INVOKE_PROPERTYPUT
End If
End Sub
Private Sub Form_Load()
OptWritable.Value = True
End Sub
Private Sub optReadOnly_Click()
If optReadOnly.Value = True Then
OptWritable.Value = False
End If
End Sub
Private Sub OptWritable_Click()
If OptWritable.Value = True Then
optReadOnly = False
End If
End Sub
Private Sub ListView1_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
Dim lstItem As ListItem
Dim intSelectedColumn As Integer
intSelectedColumn = ColumnHeader.Index - 1
ListView1.Sorted = False
If ListView1.SortOrder = lvwAscending Then
ListView1.SortOrder = lvwDescending
Else
ListView1.SortOrder = lvwAscending
End If
ListView1.Sorted = True
SortListView ListView1, ColumnHeader
Exit Sub
End Sub
Private Sub SortListView(ByRef lvwList As MSComctlLib.ListView, ByVal ColumnHeader As MSComctlLib.ColumnHeader)
If lvwList.SortKey = (ColumnHeader.Index - 1) Then
If lvwList.SortOrder = lvwAscending Then
lvwList.SortOrder = lvwDescending
Else
lvwList.SortOrder = lvwAscending
End If
lvwList.Sorted = True
Else
lvwList.SortKey = (ColumnHeader.Index - 1)
lvwList.Sorted = True
lvwList.SortOrder = lvwAscending
End If
End Sub
Last edited by TysonLPrice; Apr 9th, 2015 at 06:24 AM.