The following method will return the property (given the name of the property):
Public Function GetPropertyValue(propertyName As String) As Object
Dim pi As System.Reflection.PropertyInfo = Me.GetType().GetProperty(propertyName)
If (Not pi Is Nothing) And pi.CanRead Then
Return pi.GetValue(Me, Nothing)
End If
Dim a As Type() = Nothing
Dim mi As System.Reflection.MethodInfo = Me.GetType().GetMethod("Get" + propertyName, a)
If Not mi Is Nothing Then
Return mi.Invoke(Me, Nothing)
End If
Return Nothing
End Function
Hope this helps
source
share