
VB 6.0 Dynamic Form loading?
I would say that you should use "Objects". That is that you should
create and array of form objects, load them and then when the user
enters a form number you can use the form objects "Show" method. I
will assume that you have previously created the forms that your users
will access? If your program has only one form and that form needs to
be created multiple times, then the following would work just fine.
eg:
Dim UserForm(1 to <how many forms are in your project>) as Form1
For i 1 to 4
Set UserForm(i) =New Form1
Next i
Now when the user selects to load form, say 3, then you would use
UserForm(<user selection>).Show
and the form would pop onto the work area or desktop.
This same method would work if you have multiple forms created, you
just load as many as you need, you could create as many of the "Form?"
objects as you need for you users.
You could also use:
UserForm(<user selection>).Load
and then you could set any properties and invoke any methods
associated with this form before you actually display it on their
screen. Then when you are ready you can use:
UserForm(<user selection>).Show.
You could also just create the form objects on the fly, on an as
needed basis, when the user elects to load a new form. At that time
you could also name the forms anything that you want using the form
property: UserForm(?).Name=etc.
Hope this will help you.
Regards
Chris
Quote:
>Put your forms in array
>frmMyForm(0), frmMyForm(1) etc..
>For i = 0 to n
> load frmMyForm(i)
>Next i
>should work..
>Regards
>Tim
>> Finally, I'm learning enough about VB to have serious questions.
>> Is there anyway to load a form by deriving its name from a string?
>> For example, I have Form1, Form2, Form3, etc. Based on user input, I need to
>> load one to n forms, the number being the differentiator. The following
>> doesn't work, but it gives the idea of what I'm trying to do:
>> For i = 1 to n
>> load "form" & cstr(i)
>> next i
>> This code blows up on the load due to type mismatch. Is there anyway to
>> effect the result of loading Form1 to FormN based on the setting of N?
>> Any help would be greatly appreciated.
>> Cheers,
>> Palmer King