• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 245
  • Last Modified:

Control Array

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
LearningJava
Asked:
LearningJava
3 Solutions
 
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

~IM
0
 
Mikal613Commented:
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
 
LearningJavaAuthor Commented:
Idle Mind:
               What is count? A property? Please elaborate.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Mikal613Commented:
am i involved in this question?
0
 
Mikal613Commented:
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
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
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
 
AjithJoseCommented:
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

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now