creating a procedure to do multiple things

Posted on 2006-03-28
Last Modified: 2010-04-23
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
Question by:Orlando15767
    LVL 39

    Accepted 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

    LVL 1

    Author Comment

    yes exactly
    thanks for the help

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
    A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
    This video discusses moving either the default database or any database to a new volume.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now