I was trying to add textboxes or lables as a dynamic array. I would like to use
this data to run a excel statistics function. The code i ended up with was
'NoStdInput is the name of my listbox
Private Sub NoStdInput_Click()
Dim NoOfStds As Integer
'This is for a dynamic array of labels, was planning to do the same for
textboxes
Dim ArrayOfLbl() As Label
'Counter for the for loop
Dim I As Integer
NoOfStds = NoStdInput.Value
For I = 1 To NoOfStds
'This is for dynamiccally definign my array of lables
ReDim Preserve ArrayOfLbl(1 To I)
'To add a new label & this is where a run-time error occurs , UserForm1 is
the name of the UserForm.
Set ArrayOfLbl(I) = UserForm1.Controls.Add("Forms.Label.1","nameoflabel",
"true")
'This is to position each label
With ArrayOfLbl(I)
.Left = 10 * I
.Top = 100
.Width = 30
.Caption = "Enter your name:"
End With
Next
End Sub
Is it a good idea to add objects as a dynamic array? what could be the problem
with this code???