Opening forms based on form Type
Posted on 2006-05-25
I'm currently trying to create a unified function for opening some forms, but there are some problems when trying to utilize the Types.
For example, lets say I have 5 forms: Form1, Form2, etc.
Calling the function, I would like to use: OpenFunction(GetType(Form1))
A sample of what I've tried is:
Public Function OpenForm(ByVal FormType As Type)
Dim frm As New Form
'Find if a form of that type is already open (found in the Forms Collection). Returns a reference to the form.
frm = Forms.FindForm(FormType)
'If the form is already open, bring it to the front
If Not frm Is Nothing Then
'Otherwise, the form is not open, so create a new one
frm = New ??? 'Here is the problem
'Show the form
Is there any way to create a New form, given the Type?