Hi fellas!!!

A quick question from a complete rookie in VB.

I need to dynamically add three different types of controls into a form using loops.

I added labels and textboxes without problems.
I also added referenced updown controls that are supposed to manage the mentioned textboxes.
Setting the the basic properties of the updown control had no problem, but setting the BuddyControl property of the recently added updown control to 'buddy up' with the recently added textbox have been impossible for me. It keeps giving me this erros about not valid property value.

Here is part of the code: (notice that the dynamically added textboxes and updowns are arrays. That's because they are going to be contained by frames that are also arrays, and were also dynamically added)


Dim lblCriteria(1 To 7, 1 To 7) As Label
Dim txtCriteria(1 To 7, 1 To 7) As TextBox
Dim updUpDown(1 To 7, 1 To 7) As UpDown


For intFrameAdder = 1 To 7 Step 1
For intControlAdder = 1 To 7 Step 1
Set lblCriteria(intControlAdder, intFrameAdder) = frmCRanking.Controls.Add("VB.Label", "lblTC" & intControlAdder & intFrameAdder, frmFrame(intFrameAdder))
lblCriteria(intControlAdder, intFrameAdder).Width = 2000
lblCriteria(intControlAdder, intFrameAdder).Caption = frmPerTable.Controls("lblTC" & intFrameAdder & intControlAdder).Text
lblCriteria(intControlAdder, intFrameAdder).Visible = True
lblCriteria(intControlAdder, intFrameAdder)...... 'Other Properties for lblCriteria(intControlAdder, intFrameAdder)

Set txtCriteria(intControlAdder, intFrameAdder) = frmCRanking.Controls.Add("VB.TextBox", "txtTC" & intControlAdder & intFrameAdder, frmFrame(intFrameAdder))
txtCriteria(intControlAdder, intFrameAdder).Visible = True
txtCriteria(intControlAdder, intFrameAdder)....... 'Other Properties for txtCriteria(intControlAdder, intFrameAdder)

Set updUpDown(intControlAdder, intFrameAdder) = frmCRanking.Controls.Add("ComCtl2.UpDown", "updUD" & intControlAdder & intFrameAdder, frmFrame(intFrameAdder))
updUpDown(intControlAdder, intFrameAdder).Visible = True
updUpDown(intControlAdder, intFrameAdder)....... 'Other Properties for updUpDown(intControlAdder, intFrameAdder).

updUpDown(intControlAdder, intFrameAdder).BuddyControl = txtCriteria(intControlAdder, intFrameAdder) => Here is the problem!!

Next

Next


I would really appreaciate it if somebody could give me some insight about how to get around this problem of assigning the BuddyControl property to manage the textbox, or what should be done. Thanks in advance!!!



Andres V.