How Can I call a form that it's name is on a variable

Posted on 2006-04-17
Last Modified: 2010-04-23
I have a table with multiple record in it. Each record, when edit, must display a diferent entry form. when I bring up the record,I placed the name of the form on a variable, but now I need to call that form.

I need something like this:

Dim lcfrm As String = "FrmMntExtVnd"  ' this will be diferent for each record
Dim frmcall As windows.form
frmcall = CType(lcfrm, windows.form)
Question by:ofern01
    LVL 85

    Expert Comment

    by:Mike Tomlinson
    Use Activator.CreateInstance():

        Dim formName As String = "WindowsApplication1.FrmMntExtVnd"
        Dim frm As Form = DirectCast(Activator.CreateInstance(Type.GetType(formName)), Form)
    LVL 85

    Accepted Solution

    If you don't want to have to put the "WindowsApplication1" part in there then see RonaldBiemans answer here:
    LVL 1

    Author Comment

    Somehow I get an error saying a null reference on parameter not allowed. (with in the gettype()) and that I need to specify a New keyword
    I tried the Ronald and worked fine. Later I will try to find out why that error when it shouldn't. I just don't have time now.
    Thanks, That was great help

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Article by: Kraeven
    Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
    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 …
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    734 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

    18 Experts available now in Live!

    Get 1:1 Help Now