?
Solved

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

Posted on 2006-04-17
3
Medium Priority
?
167 Views
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)
frmcall.Show()
0
Comment
Question by:ofern01
  • 2
3 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 16472408
Use Activator.CreateInstance():

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

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 16472465
If you don't want to have to put the "WindowsApplication1" part in there then see RonaldBiemans answer here:
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_21336040.html
0
 
LVL 1

Author Comment

by:ofern01
ID: 16472583
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
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

809 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