Home > Language Reference > Classes > Form

Controls Function

Builds a list of controls.

Syntax

Public Function Controls(Optional ByVal iLayer As Integer = -1) As Collection

ParameterDescription
iLayerLayer number.

Remarks

The Controls function creates a new Collection object and populates it with all the controls of the form belonging to the specified layer. Note that each call to the function creates and returns a new object instance.

The iLayer parameter indicates the layer number; if negative or omitted, all controls are returned, whatever the layer they belong to.

This function is typically used to complete an action over all controls of a layer. The following example illustrates this by hiding all the controls belonging to the layer #9:

Private Sub Button1_Click()
  Dim c As Control
  
  For Each c In Controls(9)
    c.Visible=False
  Next
End Sub

For more information about layers, please refer to the Layer property in the Language Reference and to the Layer Window in the Programmer's Guide.

System requirements

SystemMinimal versionRemarks
Palm OSPalm OS 3.0N/A