Scratch that last dispose question. Figured it out. I used
Canfocus property of form to detect if its set to dispose.
I basically wanted to not have the same form open twice
which works fine now for forms without contructor
parameters.
However, regarding the function you gave I've added an
optional parameter to give to the form contructor an array
of types but it always gives the error: "Object reference
not set to an instance of an object".Heres the function:
Public Sub ShowForm(ByRef objForm As Windows.Forms.Form,
ByVal objFormInstance As Type, Optional ByVal Params As
Object() = Nothing) '
If IsNothing(objForm) OrElse Not objForm.CanFocus
Then
Dim ci As ConstructorInfo =
objFormInstance.GetConstructor(Type.EmptyTypes)
objForm = ci.Invoke(Params)
objForm.Show()
Else
objForm.Activate()
End If
End Sub
This particular form's contructor takes one parameter of
type string and I want to set it to "go"
The Call to the above function is:
Dim formVariable as FormName
Dim ParamArr(0) As Object
ParamArr(0) = "go"
Call ShowForm(formVariable, Type.GetType
("Namespace.FormName"), ParamArr)
Whats causeing that Error? Am I passing the array
incorrectly? or my declaring it wrong?
Thanks,
-----Original Message-----
Sebastian Santacroce wrote: This is exactly what I was looking for but its not
working.
The
Type.GetType("YourNamespace.existingForm")
is returning "Nothing".
What would I put under "YourNamespace"?
would one always exist.
The default root namespace for a VB.NET project is always
the project name,unless specified otherwise in the project properties.
--
Sven Groot
http://unforgiven.bloghorn.com
.