Dim objText

as TextBox
For i = 0 To n - 1
Set objText(i) = Me.Controls.Add("VB.TextBox", "txtMyDynamicBox" & i)
With objText(i)
.Visible = True
.BackColor = vbYellow
.ForeColor = vbBlack
End With
Next
One of the issues here is receiving events - you can't Dim WithEvents an array. The way to go about this is to create your own control which does everything a text box does but has one additional property - a notification class
Now the notification class is something else you need to create. It would look something like this:
Event Click(Index as Long)
Event DblClick(Index as Long)
Event ...
Public Sub Click(Index as Long)
RaiseEvent Click(Index)
End Sub
And so on and so forth for all of the events that you are interested in. The important thing is that each Sub has an additional Index parameter.
In you user control now, you can do the following:
Private Sub Text1_Click()
' Assume the notifier class is instantiated and called
' Notifier and that the index for this instace is
' stored in the .Tag property. Unfortunately .Index
' is read-only at run-time
Notifier.Click(Text1.Tag)
End Sub
Now, in your application:
Private WithEvents Notifier as myNotifier
' Dynamically add the control
With oControl
Set .Notifier = Notifier
...
End With
Private Sub Notifier_Click(Index)
' We have received a Click event from instance Index
' of our control
Hope this helps - its a bit of work, unfortunately.
Chaz