GetNext Method

Returns the index of the first control in the Controls Collection of the type specified.

App.ActiveForm.Controls.GetNext(Type[, Index])

Client support

   Newlook Smartclient

   Newlook Server

Use

This method is used specifically for looping through controls of a specific type on the currently active form and is useful if you wish to return a property of all controls on the form of a specific type. The StartingIndex argument can be used if you want to ignore a specified number of controls at the start of your collection (for instance, if you know that the first five controls on the screen are always screen information).

Arguments

Type - (Integer, Required)

Specifies the control type that you want to filter for. This value should be one of the pre-defined ControlType constants.

Index - (Integer, Optional)

Specifies the index of the control in the Controls Collection at which to begin the search for a control of the specified type. If left blank it will default to 0. This parameter can be used to incrementally move through the controls.

Returns

This method returns the index of the first control in the Controls Collection of the type specified. A return value of -1 indicates an invalid control or the end of the control collection.

Examples

The following example will loop through all the Label controls on the active form and set the BackColor property to red:

VB SCRIPT

'Set the Index variable

Index = App.ActiveForm.Controls.GetNext (nlCtrlLabel, 0)

 

'loop through the controls

do while Index <> -1

     App.ActiveForm.Controls(Index).BackColor = "&H000000FF"

     Index = App.ActiveForm.Controls.GetNext (nlCtrlLabel, Index +1)

loop

 

It is possible to use this method in the macro editor via the SetValue action:

MACRO EDITOR

'Set the Index variable

    SetValue(Index, 0)

    SetValue(Index, App.Activeform.Controls.GetNext(CtrlLabel, 0))

 

'loop through the controls

loop Index = -1 StopMacro

    SetValue(App.Activeform.Controls(Index).BackColor, "&H000000FF")

    SetValue(Index, App.Activeform.Controls.GetNext(CtrlLabel, Index + 1))

    GotoMacro (macroName.loop)

Applies To

Controls collection

See Also

Add Method | Remove Method | ControlType Contstants


© 2004-2021 looksoftware. All rights reserved.