MrDeveloper
asked on
is there any way to use refer to one an object's properties using a variable?
Like this:
txtBox.value = GetObjectProperty(myObject , PropertyName)
Private Function GetObjectProperty(ByVal myObject As Object, ByVal CL As Object, ByVal PropertyNameAs String) As String
Dim strResults as string
strResults = myObject.PropertyName
Return strResults
End Function
txtBox.value = GetObjectProperty(myObject
Private Function GetObjectProperty(ByVal myObject As Object, ByVal CL As Object, ByVal PropertyNameAs String) As String
Dim strResults as string
strResults = myObject.PropertyName
Return strResults
End Function
im not sure i fully understand what you are trying to do... what is your objective? maybe theres different approach...
Couldn't you just save yourself a step by doing txtBox.value = myObject.PropertyName
Depending on the Property you might need to convert in into a string first, but I guess I don't see the reason for trying to call a function to retrieve the property, when you can just ask for the property.
Depending on the Property you might need to convert in into a string first, but I guess I don't see the reason for trying to call a function to retrieve the property, when you can just ask for the property.
I think the goal here is to retrieve the property by name at run-time.... not programatically.
Every time I've seen the question, the eventual answer has been... not easily. You might be able to do it with reflection, but you take a pretty big performance hit.
Every time I've seen the question, the eventual answer has been... not easily. You might be able to do it with reflection, but you take a pretty big performance hit.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
See... I knew as soon as I said it was difficult someone would be along to prove me wrong :)
ASKER
wow Idle_Mind , that is amazing. This is really powerful - thank you so much. Worked perfectly...