Control Array

     Is there a property or object that keeps track of the total number of items in a control array?
(Please include example with code in your explanation.)
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike TomlinsonMiddle School Assistant TeacherCommented:
Sure.  If you had a textbox control array called text1, you could determine the number of textboxes in it like this:

    Private Sub Command1_Click()
        Dim arrayCount As Integer
        arrayCount = Text1.Count
        MsgBox arrayCount & " TextBoxes in Control Array Text1"
   End Sub


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
A Mini Control Array Management
Processing a Control Array

Range of Control Array Indexes

Count ,Highest and Lowest Index

YourControl.ubound = upper bound
YourControl.lbound = lower bound
YourControl.count = total number of coontrols in array

LearningJavaAuthor Commented:
Idle Mind:
               What is count? A property? Please elaborate.
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

am i involved in this question?
The Count is the Total number of Controls in your Array

A Property is a Attribute to your Control.

For example.

The Color or text is a Property of your Control
Mike TomlinsonMiddle School Assistant TeacherCommented:

It's one of the properties exposed by a control array which Mikal613 already listed:

    Text1.LBound ' The index of the last textbox in the control array
    Text1.UBound ' The index of the first textbox in the control array
    Text1.Count   ' The number of textboxes in the control array

There is one more:

    Text1.Item     ' Used to access the individual items in the array

but usually you don't see .Item() used since the following two lines are equivalent:

    Text1(1).Text = "something"
    Text1.Item(1).Text = "something"

I think this will sample code will help you:

Suppose you have an array of TextBox controls named txtArray , then

'Total no of items in the control array

MsgBox "No of Items in the Control Array=" & txtArray.Count

'You can access individual array items as

For i=txtArray.LBound to txtArray.UBound
      txtArray(i).Text="Item No: " & i


It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.