Re: Naming new form question
If you are creating a number of new forms you would probably do better to put them in a collection. In VB6 the name you are using for the form must be set up in the Dim statement so there is no way of dynamically naming each form but if you store the forms in a collection then you can refer to them as cform[1], cform[2] etc.
Re: Naming new form question
Thanks for the reply. When you say in a collection, how do I do this? I am declaring the name in the Dim statement as shown above. The form name is newForm. I assume this is just like creating an index of forms? So when I create a new form, how do I know which number it is? Is it autonumbered?
I appreciate the help!
Warren
Re: Naming new form question
this first part of code shows just adding the form to the collection. The collection should be a global variable to a form or module or to the entire project:
Code:
public cForms as collection
public sub nameofSub
dim newForm as Form
set newForm = new frmTemplate
cForms.add (newForm)
end sub
then you can retrieve the forms in other functions as shown here:
Code:
public function getForm(byval iFormNum as integer) as frmTemplate
' this function will return the form selected
' iFormNum is the number corresponding to the form in the collection
' form1 = 1, form2 = 2, etc.
set frmTemplate = cForms(iFormNum)
end function
I use this method when I have several forms in one project and the user may have already opened a form. Rather than create a new form I look through the collection for the form. If it is not in the collection then I create a new form and add it to the collection. This prevents my program from creating more than one instance of each form.