Declare and Define an Object Dynamically

Apr 19 2009 6:18 AM

Hi,
I have the following situation, can anybody help me in that?

Following is a "pseudo" code of what I want to do in VB or C# using VS.NET 2005:

In my main form I have the following
'Code Begins
Dim vCurrentForm As Form

Private Sub CallCurrentForm (ByVal pForm as String)
   If vCurrentForm Is Nothing OrElse vCurrentForm.IsDisposed Then
      vCurrentForm = <# New pForm #>
      vCurrentForm.MdiParent = Me
   ElseIf Not TypeOf vCurrentForm Is <# pForm #> Then
      vCurrentForm.Close()
      vCurrentForm = <# New pForm #>
      vCurrentForm.MdiParent = Me
   End If
   vCurrentForm.Show()
End Sub
'Code Ends

Where I am calling 'CallCurrentForm' everywhere in my menu just by passing the proper form name as a string
example: CallCurrentForm("AddNewAccount")

My problem is how to do the code between <# ... #>

Thanks


Answers (3)