PC Review


Reply
Thread Tools Rate Thread

control arrays

 
 
vb6user
Guest
Posts: n/a
 
      23rd Dec 2009
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 With Quote
 
 
 
 
Vikas Bhandari
Guest
Posts: n/a
 
      23rd Dec 2009

I never worked on Excel 5, but I do use VBA Collection for loading the
different objects. You can load textboxes in a collection and reuse the
collection. However, I don't think VBA allows to change the names on runtime.
(Please correct me if I am wrong).


--
Thanks,
Vikas Bhandari
---------------------------
http://excelnoob.blogspot.com


"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

 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      23rd Dec 2009
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

 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      23rd Dec 2009
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" <(E-Mail Removed)> wrote in message
news:8D546E0D-63B9-4F11-A971-(E-Mail Removed)...
> 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Control Arrays Tony Wainwright Microsoft Access Form Coding 1 9th Feb 2005 10:16 AM
Control Arrays Tim Boalch via .NET 247 Microsoft Dot NET Compact Framework 0 22nd Dec 2004 11:53 PM
Control Arrays? SixSigmaGuy Microsoft Excel Programming 5 11th Nov 2004 10:47 AM
Control array of control arrays? =?Utf-8?B?RnJlZXp5?= Microsoft C# .NET 0 1st Mar 2004 03:21 PM
Control Arrays Charles Microsoft Access Form Coding 1 27th Jan 2004 03:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:28 AM.