Solved

createobject to instance a vb6 form?

Posted on 2006-06-21
4
1,276 Views
Last Modified: 2008-02-01
Hi

Is there any way to instance a vb6 form using only the name of the form in vb6?

eg: set frm = createobject("form1")

(this doesn't work)

I want to be able to instance a form from it's name which will be stored in a string.
0
Comment
Question by:daniel_j_c
  • 2
4 Comments
 
LVL 51

Expert Comment

by:Ryan Chong
ID: 16949534
trY:

dim frm as form1
set frm = new form1
...
0
 
LVL 2

Author Comment

by:daniel_j_c
ID: 16949659
ok, here's a little background...

I want to be able to store the names of forms in a database in a "tasks" table. The tasks table has the name of the form to be instanced and an associated task name eg:

Form                    Task Name
frmclientdetails      New Client

I want to be able to create an instance of the form frmclientdetails using the string "frmclientdetails". I can't use "= new frmclientdetails" because that would require me to create a select case statement like this:

select case FormName
case "frmclientdetails": set frm=new frmclient details
...
end select

Which is why I want to use something like createobject().
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 16951477
Something like...
   
    Private Sub Command1_Click()
        Dim frmName As String
        frmName = "Form2"
   
        Dim frm As Form
        Set frm = Forms.Add(frmName)
        frm.Show
    End Sub

0
 
LVL 2

Author Comment

by:daniel_j_c
ID: 16951531
can't believe it's that simple! i've been looking for something like this for years!
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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…

820 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