Responding to Events using the ActiveX Control on a Visual Basic Form

This sample code could be applied to a form that has a Reflection for IBM control. The project should include a reference to the Reflection for IBM object library.

When the form loads:

· The Reflection for IBM control is configured to connect to a demonstration host

· An event is defined using the OnEvent method. This event triggers the RaiseControlEvent method.

When you display the page and connect to the host (by clicking the connect button), the event procedure uses OnReflectionEvent to display the string data sent from Reflection.


Private Sub Form_Initialize()

Set Ribm = RibmCtrl1.GetActiveSession

With Ribm

'Configure connection

Ribm.SetupSession rc5250Terminal, rc31792, rcDemo

.HostName = "ribm5250.sim"


'Define an event to take place when a connection is made

.OnEvent rcNextEvent, _

rcEvConnected, _

"RaiseControlEvent 0, ""Connected!""", _

rcEnable, _

rcEventReEnable, _

"", 0, 0

End With

End Sub


Private Sub RibmCtrl1_OnReflectionEvent(ByVal v1 As Long, ByVal v2 As String)

'Display string value from ReflectionControlEvent

MsgBox v2, , "Reflection"

End Sub