Difference between revisions of "Create Object from String"

From Logic Wiki
Jump to: navigation, search
m (Macrop moved page VB.NET Create Object from String to Create Object from String without leaving a redirect)
 
m (1 revision imported)
 
(No difference)

Latest revision as of 14:27, 9 May 2016

Dynamically Create Object From String

Public Function DynamicallyLoadedObject(ByVal objectName As String, Optional ByVal args() As Object = Nothing) As Object
  Dim returnObj As Object = Nothing
  Dim type As Type = Assembly.GetExecutingAssembly().GetType(Application.ProductName & "." & objectName)
  If Not type Is Nothing Then
   returnObj = Activator.CreateInstance(type, args)
  End If
  Return returnObj
 End Function