Can I use Reflection or some other method to get a reference to a specific instance of a class from the name of this instance of the class?
For example, the infrastructure for applications that I actively use uses instances of a public class, such as: Public bMyreference as MyReference = new MyReference
Then, throughout the application, bMyReference is used by custom controls and code.
One of the properties of custom controls is the "Field Name", which refers to the property in these class instances (bMyReference.MyField) as a string.
What I would like to do is parse this line of "bMyReference.MyField" and then go back to the actual instance / property.
In VB6, I would use EVAL or something to simulate to convert the string to an actual object, but this obviously does not work in VB.net
What I imagine is something like this
Dim FieldName as String = MyControl.FieldName ' sets FielName to bMyReference.MyField Dim FieldObject() as String = FieldName.Split(".") ' Split into the Object / Property Dim myInstance as Object = ......... ' Obtain a reference to the Instance and set as myInstance Dim myProperty = myInstance.GetType().GetProperty(FieldObject(1))
user292530
source share