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: 189
  • Last Modified:

creating a procedure to do multiple things

I'm new to VB.NET and am creating an MDI application.

What I would like to do is create a procedure to accomplish a few simple tasks

the tasks that I want to complete by calling a procedure is:

        [form name]= New [form name]
        [form name].MdiParent = Me
        [form name].Show()

I want to do this because it seems pointless to write the 3 lines of code every time I want to create a new child form

thanks for the help
1 Solution
is this what you are looking for?

   Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click
        openMyForm(New Form3)
    End Sub

   Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
        openMyForm(New Form1)
    End Sub

    Private Sub openMyForm(ByVal frm As Object)
        Dim frmNew As Form
        frmNew = frm
        frmNew.MdiParent = Me
    End Sub

Orlando15767Author Commented:
yes exactly
thanks for the help

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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