Create a combobox on your form in design view. Assign the index property
the value 0 to turn this into a control array. You can then create new
instances of the combobox in this array on the fly with something like:
Load cboArray(cboArray.Ubound + 1)
Then to refer to this new combobox use cboArray(cboArray.Ubound)
For example to create a column of 10 comboboxes, each with 5 pixels between
them:
Dim ix As Integer
For ix = 1 To 10
Load cboArray(cboArray.Ubound + 1) ' load next combobox
' work with the new combobox
With cboArray(cboArray.Ubound)
.Top = cboArray(cboArray.Ubound - 1).Top + _
cboArray(cboArray.Ubound - 1).Height + _
5 * Screen.TwipsPerPixelY
.Visible = True ' make sure you set this, as otherwise the new
comboboxes might not be visible
End With
Next ix
Don't know about doing forms on the fly though.
Hope this helps,
Adam
"aaa" <jo************@hotmail.com> wrote in message
news:4K*********************@news20.bellglobal.com ...
Hello to all,
In an application under VB6, I need to fill some ComboBoxes with data.
However, I don't know in advance how many ComboBoxes I will need. I could
of course create many (maybe 15 or 20) and only use those that I need.
However, I would rather like to programmatically create and them to my
form. How can this be achieved? Also, is there a generic method that could be
used with other objects? (For example, programmatically create new
forms.)
Thank you in advance for you help.
John H. Dewbert
jo************@hotmail.com