Solved

createobject to instance a vb6 form?

Posted on 2006-06-21
4
1,268 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 50

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
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 …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

773 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