Reflection Desktop VBA Guide
Attachmate.Reflection.Objects.Emulation.OpenSystems Library / Attachmate.Reflection.Objects.Emulation.OpenSystems Library / Screen Object / DefineEvent Method
The Long value used as an identifier for this event. If the value is set to 0, a value is automatically assigned.
A DefinedEventType value that specifies the event type being defined.
Specifies information corresponding to the event type. For DefinedEventType_TimeElapsed and DefinedEventType_Silence, this specifies an interval of time in HH:MM:SS format, For DefinedEventType_TimeOfDay, this specifies time of day. For DefinedEventType_ReceiveString and DefinedEventType_DisplayString, it specifies the string. For other event types, it is ignored.
The screen row position (the first row = 1). Mandatory for EventTypes that require a Row parameter, otherwise ignored.
The screen column position (the first column = 1). Mandatory for EventTypes that require a Column parameter, otherwise ignored.
Example
In This Topic
    DefineEvent Method (Screen)
    In This Topic
    Defines a specific event. The event remains defined until it is removed with a RemoveEvent or ClearEvent call or the host session is closed.
    Syntax
    expression.DefineEvent( _
       ByVal EventNumber As Integer, _
       ByVal EventType As DefinedEventType, _
       ByVal StringParam As String, _
       ByVal Row As Integer, _
       ByVal Column As Integer _
    ) As Integer
    where expression is a variable that represents a Screen Object

    Parameters

    EventNumber
    The Long value used as an identifier for this event. If the value is set to 0, a value is automatically assigned.
    EventType
    A DefinedEventType value that specifies the event type being defined.
    StringParam
    Specifies information corresponding to the event type. For DefinedEventType_TimeElapsed and DefinedEventType_Silence, this specifies an interval of time in HH:MM:SS format, For DefinedEventType_TimeOfDay, this specifies time of day. For DefinedEventType_ReceiveString and DefinedEventType_DisplayString, it specifies the string. For other event types, it is ignored.
    Row
    The screen row position (the first row = 1). Mandatory for EventTypes that require a Row parameter, otherwise ignored.
    Column
    The screen column position (the first column = 1). Mandatory for EventTypes that require a Column parameter, otherwise ignored.

    Return Value

    Assigned event number
    Remarks
    Do not try to use VBA DefineEvent method / DefinedEvent event infrastructure and legacy COM DefineEvent/DefinedEvent infrastructure from within a single active session. This will not work properly as there are differences in functionality between the two and they each utilize the same resources in the underlying connectivity code.
    Example
    This example defines an event to fire when there is no host activity for 30 seconds. Then it handles the event to disconnect the session.
    'Put this code in the ThisTerminal code window
    Private Sub Terminal_Connected(ByVal sender As Variant, ByVal ConnectionID As Long, ByVal connnectionType As Attachmate_Reflection_Objects_Emulation_OpenSystems.ConnectionTypeOption, ByVal connectionSettings As Variant)
        
        'Define an event that occurs when there is no host activity for 30 seconds
        ThisScreen.DefineEvent 1, DefinedEventType_Silence, "00:00:30", 1, 1
        
    End Sub
     
    'Put this code in the ThisScreen code window
    'The following procedure is executed when a defined event triggers.
    Private Sub Screen_DefinedEvent(ByVal EventNumber As Long, ByVal EventType As Attachmate_Reflection_Objects_Emulation_OpenSystems.DefinedEventType, ByVal TheString As String, ByVal row As Long, ByVal column As Long)
         
         'If the host is inactive for the specified interval, disconnect
         If EventNumber = 1 Then
             ThisTerminal.Disconnect
         End If
         
     End Sub
    See Also