Try
Dim classType As Type = GetType(Form1)
Then call the method:
DisplayForm(classType)
Then you can use the information and reflection of this type to instantiate the runtime in the DisplayForm method:
Activator.CreateInstance(classType)
Please note that this is a simple example and does not perform error checking, etc. You should read a little more about reflection to make sure that you are dealing with any potential problems.
Change 1:
A simple example:
Public Class MyClass Public Shared Sub DisplayForm(ByVal formType As Type) Dim form As Form = DirectCast(Activator.CreateInstance(formType), Form) form.ShowDialog() End Sub End Class
You use a method like:
Dim formType As Type = GetType(Form1) MyClass.DisplayForm(formType)
Again, it is best to do some error checking in all of this.
source share