InfoConnect VBA Guide
Attachmate.Reflection.Objects.Framework Library / ApplicationObject Object / GetControlsByName Method
Name of control.
Example
In This Topic
    GetControlsByName Method
    In This Topic
    Gets a collection of controls by name.
    Syntax
    expression.GetControlsByName( _
       ByVal name As String _
    ) As Object()
    where expression is a variable that represents a ApplicationObject Object

    Parameters

    name
    Name of control.

    Return Value

    A collection of terminal controls whose names all match the name.
    Example
    This sample toggles the connection state for all controls in an array.
    Sub ToggleConnection()
    'Give the Ibm terminal a name. This will provide ability to retrieve
    'the session with Application.GetControlsByName.
    'This could be done for each session, perhaps on AfterConnect event.
    ThisIbmTerminal.Name = "IBMSession1"
    'The following demonstrates getting a set of sessions/controls with a given name
    Dim controls() As Variant 'An array of type Variant/Object/Terminal
    'Return all controls named "IBMSession1"
    controls = Application.GetControlsByName("IBMSession1")
    If UBound(controls) = -1 Then
        Exit Sub
        Else
        'Toggle the connection state for all controls in array
            For i = 0 To UBound(controls)
            If controls(i).IsConnected Then
            controls(i).Disconnect
        Else
            controls(i).Connect
        End If
        Next i
    End If
    End Sub
    See Also