VS6 - How do I show a form when I only have its name as a string?

Hi Experts,

I have a variable that holds a string value of a name of one of the forms I have in VB6 project.

I need to show this form, by using the string value of the variable. Is that possible?

-------------------------
Example:
-------------------------
Dim X as String
X= "Form1"

I need something like X.show or Forms(X).show



Thanks in advance!
feesuAsked:
Who is Participating?
 
Jupiler78Connect With a Mentor Commented:
Hello feesu,

try this:
Dim frm As Form
Dim X as String

x = "Form1"
Set frm = Forms.Add x
frm.Show

Regards,

Jupiler78
0
 
feesuAuthor Commented:
Hello Jupiler,

I get an error on the line:

Set frm = Forms.Add x

Error: Expected end of statement
0
 
feesuAuthor Commented:
Jupiler,

This solved it:

Set frm = Forms.Add(x)

Thanks!
0
 
Jupiler78Commented:
feesu,

that is right, my fault. :)
glad you found it.
good luck.

Jupiler78
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.