Thread: control arrays
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default control arrays

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