Open form by variable

Posted on 2005-03-01
Medium Priority
Last Modified: 2010-04-17
do u have any idea to open a form dynamically by putting the form name in some variable and open the form using that variable.
dim x as variable
x.show 'must open the form whose name is stored by x


Question by:binita11
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 13428489
If you have a form, say called frmUserInput:

then you can say this:

Dim newForm as frmUSerInput

and later on
set newform = new frmUserInput
newform.show vbmodal and so on.

LVL 86

Expert Comment

by:Mike Tomlinson
ID: 13429252
Assuming VB6:

Private Sub Command1_Click()
    Dim frmName As String
    frmName = "Form2"
    Dim frm As Form
    Set frm = Forms.Add(frmName)
End Sub

Accepted Solution

GuryTraub earned 250 total points
ID: 13429391
if I understand correctly what you mean, and you are using .net then you can use reflection to load a certain class dynamically, meaning load it's assembly (dll file), and then call one of its constructors (or other methods/properties/etc) then you'll have an object which you can case to a window.form.

take a look at the reflection samples in the help.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This is about my first experience with programming Arduino.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

777 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