From: vb6user on
I'm using VBA with Excel 5 and developing a form. Under VB6 I'd create a
control array to allow me to access 10 text boxes using a loop. VBA doesn't
appear to allow this. Is there any way to simulate a control array eg by
programatically modifying the names of the text boxes?

Thanks
From: Jacob Skaria on
VBA do not allow control arrays. Instead you can consider one of the below
two approaches


'------If the textboxes are named as TExtbox1,TExtbox2 ...Textbox10
Dim intCount as Integer
For intCount = 1 To 10
Me.Controls("Textbox" & intCount).Text = intCount
Next

'-------If you are not sure of the textbox names you can try the below
Dim Ctl As MSForms.Control
For Each Ctl In UserForm1.Controls
If TypeOf Ctl Is MSForms.TextBox Then
' do something
MsgBox Ctl.Name

End If
Next
--
Jacob


"vb6user" wrote:

> I'm using VBA with Excel 5 and developing a form. Under VB6 I'd create a
> control array to allow me to access 10 text boxes using a loop. VBA doesn't
> appear to allow this. Is there any way to simulate a control array eg by
> programatically modifying the names of the text boxes?
>
> Thanks
From: Bob Phillips on
You can emulate a control array with an event class, but unfortunately not
all of the events are exposed to this class. Which events are you after?


---
HTH

Bob Phillips

"vb6user" <vb6user(a)discussions.microsoft.com> wrote in message
news:8D546E0D-63B9-4F11-A971-9B0745F38B7A(a)microsoft.com...
> I'm using VBA with Excel 5 and developing a form. Under VB6 I'd create a
> control array to allow me to access 10 text boxes using a loop. VBA
> doesn't
> appear to allow this. Is there any way to simulate a control array eg by
> programatically modifying the names of the text boxes?
>
> Thanks