Solved

Control Array

Posted on 2004-10-27
227 Views
Last Modified: 2010-05-02
Hi:
     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.)
0
Question by:LearningJava
    7 Comments
     
    LVL 85

    Accepted Solution

    by:
    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

    ~IM
    0
     
    LVL 48

    Expert Comment

    by:Mikal613
    A Mini Control Array Management
    --------------------------------------------
    Processing a Control Array

        http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20174598.html

    Range of Control Array Indexes

        http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_10261311.html

    Count ,Highest and Lowest Index

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

    0
     

    Author Comment

    by:LearningJava
    Idle Mind:
                   What is count? A property? Please elaborate.
    0
     
    LVL 48

    Expert Comment

    by:Mikal613
    am i involved in this question?
    0
     
    LVL 48

    Assisted Solution

    by:Mikal613
    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
    0
     
    LVL 85

    Expert Comment

    by:Mike Tomlinson
    Right.

    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"

    ~IM
    0
     
    LVL 4

    Assisted Solution

    by:AjithJose
    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
    Next

    ~Ajith

    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Introduction This article makes the case for using two modules in your VBA/VB6 applications to provide both case-sensitive and case-insensitive text comparison operations.  Recently, I solved an EE question using the LIKE function.  In order for th…
    I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    856 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now