You don't have a single
Return
statement anywhere. This isn't VB6 or VBScript.
An actual Return statement has to be in there, and in an appropriate place. If you replace the
GetPropertyValue = .Value
with the Return statement, you'll get another error, "Not all code paths return a value."
So, rewrite the function
Public Function GetPropertyValue(objBlockRef As AcadBlockReference, propName As String) As Object
Dim iProp As Long
Dim dybprop As Object
Dim returnValue As Object = Nothing
If objBlockRef.IsDynamicBlock Then
dybprop = objBlockRef.GetDynamicBlockProperties
For iProp = LBound(dybprop) To UBound(dybprop)
properties
If dybprop(iProp).PropertyName = propName Then
returnValue = dybprop(iProp).Value
Exit For
End If
Next
End If
Return returnValue
End Function