title: Obtaining reference to Class instance by string name - VB.NET
body: <p>Is it possible using Reflection or some other method to obtain a reference to a specific class instance from the name of that class instance?</p>
  
  <p>For example the framework for the applications i develop heavily uses public class instances such as:
    Public bMyreference as MyReference = new MyReference</p>
  
  <p>Then throughout the application bMyReference is used by custom controls and code.</p>
  
  <p>One of the properties of the custom controls is the "FieldName" which references a Property in these class instances (bMyReference.MyField) as a string.</p>
  
  <p>What i would like to be able to do is analyze this string "bMyReference.MyField" and then refer back to the actual Instance/Property.</p>
  
  <p>In VB6 I would use an EVAL or something simular to convert the string to an actual object but this obviously doesn't work in VB.net</p>
  
  <p>What I'm picturing is something like this</p>
  
  <pre><code>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))
  </code></pre>