Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 169
  • Last Modified:

Reflection and Forms

I am using the following code to create a form based on a key value from a toolbar, is this the correct way of doing it. I have stitched it together from various exmaples. My concern starts with the first line is this right

   Dim asm As Assembly = Assembly.GetExecutingAssembly
            Dim formObj As Type = asm.GetType("Aquarius." & e.Item.Key)
            Dim formActivator As Object = Activator.CreateInstance(formObj)
            frm = DirectCast(formActivator, Form)
            If frm.Name.Substring(0, 4) = "View" Then
                frm.MdiParent = Me
            End If
1 Solution
Bob LearnedCommented:
1) If it works, go with it.

2) It looks good to me.

3) I would simplify a little:

    Dim formActivator As Form = DirectCast(Activator.CreateInstance(formObj), Form)

    If frm.Name.StartsWith("View") Then


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now