It's not so easy as "dim frm as new "& formname &"", but it can be done doing something like this:
Dim frmNewForm As Form = Nothing
Dim frmNewForm_Type As Type = Type.GetType("your_assembly.type_name")
frmNewForm = CType(Activator.CreateInstance(frmNewForm_Type), Form)
I mean, you have to store the Type of the class form.
Edit:
You can open a form so:
Dim oFr as New frmBill
oFr.Show()
ok? Well. You can open a Form so:
Dim oFr as Form
oFr = New frmBill ' Because frmBill inherits System.Windows.Forms.Form class. All forms do it
oFr.Show()
Here, frmBill its the Type of the class. You have no frmBill explicit reference, so you have to load it dinamically.
How can be do? Using a "NET mechanism" called Reflection. You can create a class dinamically, specifing the class Type.
Dim frmNewForm As Form = Nothing
Dim frmNewForm_Type As Type = Type.GetType("project_name.frmBill")
frmNewForm = CType(Activator.CreateInstance(frmNewForm_Type), Form)
What is Plutonix saying? Suppose you have a public "Print" method in frmBill.
With my answer, you can't do this:
frmNewForm.print()
Because you only can access to System.Windows.Forms.Form methods (close, show, showdialog...)
You can improve this, using a custom base class, or using Interfaces, or base abstract class... as you need. You can combine different ideas, depending on what you need. For example, you can combine an Interface with a Superclass:
public class frmMyForms
inherits System.Windows.Forms.Form
public sub store_data ()
....
public interface IInterface_common_methods
sub print ()
...
public class frmBill
inherits frmMyForms
implements IInterface_common_methods
public overloads sub store_data ()
msgbox ("store")
end sub
public sub print () implements IInterface_common_methods.print
msgbox ("print")
end sub
Now, you could do things like:
Dim frmNewForm As frmMyForms= Nothing
Dim frmNewForm_Type As Type = Type.GetType("project_name.frmBill")
frmNewForm = CType(Activator.CreateInstance(frmNewForm_Type), frmMyForms)
frmNewForm.Show()
frmNewForm.store_data()
ctype(frmNewForm, IInterface_common_methods).Print()
I don't know if this is wthat you're looking for, but I hope this can help you to learn more about NET possibilities.