Solved

createobject to instance a vb6 form?

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

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
sumDigits  challenge 7 62
mapShare challenge 13 69
control image tags in a string ? 12 70
Birthdays 3 21
A short article about a problem I had getting the GPS LocationListener working.
A short article about problems I had with the new location API and permissions in Marshmallow
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 seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

746 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now