Create Object from String

From Logic Wiki
Jump to: navigation, search

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