Click to See Complete Forum and Search --> : Convert string to form
hawkcg
April 9th, 2001, 08:58 AM
I am not sure about which category to put this in. Anyway, what I am trying to do is this. I have names of forms stored in a database and want to use these values to load the forms. In order to keep from hard coding anything in the program, I want to accept the string from the database, convert the string value to a form object, and then load the form. Then I can get the window handle, which is really why I am going through this song and dance to begin with. Any ideas, let me know.
Thanks in advance,
cginn@mmcable.com
Cimperiali
April 9th, 2001, 09:53 AM
This is Bruno solution to this matter.
Use Add method of Forms collection:
Forms.Add("Form1").Show
You'll need VB6 SP3 for Forms.Add to work. Without SP3 it won't work when compiled.
option Explicit
private Sub Form_Click()
Dim x as Form, strName as string
strName = "Form1"
set x = Forms.Add(strName)
x.Show
End Sub
Hope it help you too
Cesare Imperiali
Special thanks to Lothar "the Great" Haensler. Come back soon, you Guru.
hawkcg
April 9th, 2001, 10:23 AM
Well, I am running VB6 with SP4 and I can't get ths Forms.Add to work. I get error 424, object required. Any hints to make this work?
hawkcg
April 9th, 2001, 10:33 AM
Never mind. I had something typed wrong. That works great. Thanks so much!!!!
Cimperiali
April 9th, 2001, 11:08 AM
Thanks to Bruno (we will miss him).
Best regards,
Cesare Imperiali
Special thanks to Lothar "the Great" Haensler. Come back soon, you Guru.
deep_nsk
January 20th, 2006, 06:45 AM
Dear Cimperiali
thank u very much, it work properly
Deepak
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.