Reflection Desktop VBA Guide
Attachmate.Reflection.Objects.Emulation.IbmHosts Library / Attachmate.Reflection.Objects.Emulation.IbmHosts Library / IbmScreen Object / DefineEvent Method
The Long value to be used as an identifier for this event. If the value is set to 0 then a value will be automatically assigned.
The event type being defined.
Specifies an interval of time in HH:MM:SS format. The specified event must last this long to satisfy the definition. This argument is only relevant when the value you use for the EventType argument requires a duration. That is, when EventType is DefinedEventType_Silence or DefinedEventType_KeyboardEnabled. The interval begins when the DefineEvent method is executed.
Specifies the string that defines string-oriented events. This argument is only relevant when the value you use for EventType requires a string. That is, when EventType is DefinedEventType_DisplayString, DefinedEventType_TimeOfDay, or DefinedEventType_TimeElapsed.
Specifies the row location for screen events. Use a row number to specify a particular row. When EventType is DefinedEventType_DisplayString, you can use 0 to indicate that the event can occur at any row location. This argument is relevant when EventType is DefinedEventType_CursorEnterField, DefinedEventType_CursorExitField, DefinedEventType_CursorEnterPosition, DefinedEventType_CursorExitPosition, or DefinedEventType_DisplayString.
Specifies the column location for screen events. Use a column number to specify a particular column. When EventType is DefinedEventType_DisplayString, you can use 0 to indicate that the event can occur at any column location. This argument is relevant when EventType is DefinedEventType_CursorEnterField, DefinedEventType_CursorExitField, DefinedEventType_CursorEnterPosition, DefinedEventType_CursorExitPosition, or DefinedEventType_DisplayString.
Example
In This Topic
    DefineEvent Method (IbmScreen)
    In This Topic
    Defines a specific event.
    Syntax
    expression.DefineEvent( _
       ByVal EventNumber As Integer, _
       ByVal EventType As DefinedEventType, _
       ByVal Duration As String, _
       ByVal StringParam As String, _
       ByVal Row As Integer, _
       ByVal Column As Integer _
    ) As Integer
    where expression is a variable that represents a IbmScreen Object

    Parameters

    EventNumber
    The Long value to be used as an identifier for this event. If the value is set to 0 then a value will be automatically assigned.
    EventType
    The event type being defined.
    Duration
    Specifies an interval of time in HH:MM:SS format. The specified event must last this long to satisfy the definition. This argument is only relevant when the value you use for the EventType argument requires a duration. That is, when EventType is DefinedEventType_Silence or DefinedEventType_KeyboardEnabled. The interval begins when the DefineEvent method is executed.
    StringParam
    Specifies the string that defines string-oriented events. This argument is only relevant when the value you use for EventType requires a string. That is, when EventType is DefinedEventType_DisplayString, DefinedEventType_TimeOfDay, or DefinedEventType_TimeElapsed.
    Row
    Specifies the row location for screen events. Use a row number to specify a particular row. When EventType is DefinedEventType_DisplayString, you can use 0 to indicate that the event can occur at any row location. This argument is relevant when EventType is DefinedEventType_CursorEnterField, DefinedEventType_CursorExitField, DefinedEventType_CursorEnterPosition, DefinedEventType_CursorExitPosition, or DefinedEventType_DisplayString.
    Column
    Specifies the column location for screen events. Use a column number to specify a particular column. When EventType is DefinedEventType_DisplayString, you can use 0 to indicate that the event can occur at any column location. This argument is relevant when EventType is DefinedEventType_CursorEnterField, DefinedEventType_CursorExitField, DefinedEventType_CursorEnterPosition, DefinedEventType_CursorExitPosition, or DefinedEventType_DisplayString.

    Return Value

    Assigned event number
    Remarks
    Do not try to use VBA DefineEvent method / DefinedEvent event infrastructure and legacy Reflection 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 that occurs when there is no host activity for 30 seconds and handles the event to disconnect the session.
    'Place this code in the ThisIbmTerminal code window
    Private Sub IbmTerminal_AfterConnect(ByVal sender As Variant)
        
        ThisIbmScreen.ClearEvents
     
        'Define an event that occurs when there is no host activity for 30 seconds
        ThisIbmScreen.DefineEvent 1, DefinedEventType_Silence, "00:00:30", " ", 0, 0
        
    End Sub
     
    'Place this code in the ThisIbmScreen code window. The following procedure is executed when a defined event triggers.
    Private Sub IbmScreen_DefinedEvent(ByVal EventNumber As Long, ByVal EventType As Attachmate_Reflection_Objects_Emulation_IbmHosts.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
            ThisIbmTerminal.Disconnect
        End If
        
    End Sub
    See Also