>*property is called _Propmaster > >varstr = "Propmaster" >prop = "_"+varstr+".count" > >mycount = eval(prop) >>
' Return a reference to a control by the use of its name ' expO1 Form ' expC1 Name of the control Public Function FindControlByFieldName(ByVal loForm As System.Windows.Forms.Form, ByVal tcProperty As String) As Object Dim loFieldInfo As System.Reflection.FieldInfo = Nothing Dim loObject As Object = Nothing Dim loPropertyInfo As System.Reflection.PropertyInfo = Nothing Dim loType As System.Type = Nothing ' Get the form type loType = loForm.GetType() ' Get the property info loPropertyInfo = loType.GetProperty(tcProperty, System.Reflection.BindingFlags.Public Or _ System.Reflection.BindingFlags.NonPublic Or System.Reflection.BindingFlags.Instance Or _ System.Reflection.BindingFlags.DeclaredOnly) ' If the property info is known as an object If Not loPropertyInfo Is Nothing Then Return loPropertyInfo.GetValue(loForm, Nothing) End If ' Get the field info loFieldInfo = loType.GetField(tcProperty, System.Reflection.BindingFlags.Public Or _ System.Reflection.BindingFlags.NonPublic Or System.Reflection.BindingFlags.Instance Or _ System.Reflection.BindingFlags.DeclaredOnly) ' If the field info is nothing If loFieldInfo Is Nothing Then Return Nothing End If ' Get the field object loObject = loFieldInfo.GetValue(loForm) Return loObject End Function