Dynamic menus

Can we in VB6 dynamically add to a menu control array and if so is there a limit of elements we can add to the array? If can, please snippets of code.
Who is Participating?
avitalkConnect With a Mentor Commented:
a menu array is like any other control array.  you insert the first element in design time and the rest you can put in at run time.

I don't know if there's a limit, I think the only limit in this case would be display problems.
I added 100 items, there was no error

but i simply couldn't see then all.

open a new form, insert two menu items:
first is mnuFather
and the second is a sub menu - mnuDyn, with index = 0

here's the code:

Private Sub Command1_Click()
Dim count As Long, I As Long, NewIndex As Long

count = 30
For I = 1 To count
    NewIndex = mnuDyn.LBound + I
    Load mnuDyn(NewIndex)
    mnuDyn(NewIndex).Caption =  _
         "Dynamic" & CStr(NewIndex + 1)
    mnuDyn(NewIndex).Visible = True
End Sub

All Courses

From novice to tech pro — start learning today.