Load a form

VB 6
i have a textbox
in this the user will type name of a form

i have to show the form

i do not want to check each form's name
with the name in the textbox

i want some other logic
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TimCotteeHead of Software ServicesCommented:
There is no easy way of doing this, perhaps an alternative method would be to create a combobox which you fill with the valid form names either by iterating through the forms collection or otherwise.
In VB6 + SP3:

Forms.Add "Form2"

Dim objForm As Form
Set objForm = Forms(Forms.Count - 1)

With thanks to ameba.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial

Forms.Add YourTextBox.Text
Ensure Business Longevity with As-A-Service

Using the as-a-service approach for your business model allows you to grow your revenue stream with new practice areas, without forcing you to part ways with existing clients just because they don’t fit the mold of your new service offerings.


You'll have great fun distinguishing between multiple instances of the same form ;-)
TimCotteeHead of Software ServicesCommented:
Didn't think about that one, but I agree it will be great fun trying to find out which form is which!

..and if you were to increase the number of points to a decent amount I'll even tell you how.
You can't add to the forms collection !!!!!!!!!!!!!!

Declare a custom collection at module level
mcolForms as New Collection

'on form load ...
dim objForm as form
for each objForm in Forms
  mcolForms.Add objForm,objForm.Name
next objForm

'Then, when the user types a form name,
'retrieve the form by using ...


'Use error handling in case they typed
'a name that does not exist in the 'collection.

On error goto ?
Éric MoreauSenior .Net ConsultantCommented:
Look in the help for CallByName.
You can't add to the forms collection !!!!!!!!!!!!!!

Yes you can, in VB6 + SP3. New feature, very nice!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.