[go: up one dir, main page]

0% found this document useful (0 votes)
4 views6 pages

CTRL Array

A control array is a group of controls that share the same name and type and event procedures. Control arrays allow adding multiple controls using fewer resources than adding individual controls. Control arrays are also useful when multiple controls need to share the same code, such as option buttons performing the same action. Control arrays can be created at runtime using Load and Unload statements to dynamically add and remove array elements.

Uploaded by

Thaddeus Moore
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views6 pages

CTRL Array

A control array is a group of controls that share the same name and type and event procedures. Control arrays allow adding multiple controls using fewer resources than adding individual controls. Control arrays are also useful when multiple controls need to share the same code, such as option buttons performing the same action. Control arrays can be created at runtime using Load and Unload statements to dynamically add and remove array elements.

Uploaded by

Thaddeus Moore
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 6

Control Arrays

A control array is a group of controls that share the


same name and type.

They also share the same event procedures.

A control array has at least one element and can
grow to as many elements as your system resources and
memory permit;

Its size also depends on how much memory and
Windows resources each control requires.

The maximum index you can use in a control array is
32767.
Why Use Control Arrays?
Adding controls with control arrays uses fewer
resources than simply adding multiple controls of
the same type to a form at design time.
Control arrays are also useful if you want several
controls to share code.
For example, if three option buttons are created
as a control array, the same code is executed
regardless of which button was clicked.


Private Sub cmdTest_Click(Index As Integer)
Print cmdTest(Index).Caption
End Sub

Creating Controls at Run Time

Control arrays can be created at run time
using the statements
Load object (Index %)
Unload object (Index %)

The Load Stmt

Private Sub Form_Load()
Dim i As Integer
For i = 2 To 5
Load txtamt(i)
txtamt(i).Text = "Text box #" + Str$(i)
End Sub
The Unload Stmt

Private Sub Form_Click()
Static i As Integer
If i < 4 Then
Unload txtamy(i + 2)
i = i + 1
Else
Exit Sub
End If
End Sub

You might also like