Solved

createobject to instance a vb6 form?

Posted on 2006-06-21
4
1,314 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
[X]
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
  • 2
4 Comments
 
LVL 52

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 86

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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

This is about my first experience with programming Arduino.
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.
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…
Starting up a Project

632 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