Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default control arrays

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 834
Default control arrays

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" wrote in message
...
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Control arrays on Excel 2007 userforms Informative Excel Discussion (Misc queries) 1 February 26th 08 09:36 PM
Arrays - declaration, adding values to arrays and calculation Maxi[_2_] Excel Programming 1 August 17th 06 04:13 PM
Control Arrays Charles Watson Excel Programming 2 November 14th 04 01:52 PM
Control Arrays? SixSigmaGuy Excel Programming 5 November 11th 04 10:47 AM
On the lack of control arrays. Jan Nordgreen Excel Programming 3 October 11th 03 12:11 AM


All times are GMT +1. The time now is 07:35 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"