AdsReadConnectUpdate
This event is called if the AdsReadYY(Var)Connect() method has been called, and the value from the ADS device has been read or has changed.
object_AdsReadConnectUpdate(
nIndexGroup As Long,
nIndexOffset As Long
)
Parameter
nIndexGroup
[out] Date and time at which the message was issued by the ADS device
nIndexOffset
[out] Milliseconds as the message was issued by the ADS device
Comments
With the AdsReadConnectUpdate() event, it is not necessary that the value is transmitted at the same time, since the ADS-OCX will be updating the Visual Basic variable in the background. To optimize write accesses to display objects on the form, the event function should query which variable has changed and update only the element on the form that displays the value. If a VB variable was connected to an ADS variable via VarConnect, the handle of the variable is passed in the parameter nIndexOffset in the event AdsReadConnectUpdate(). The constant value &HF005 is transferred to the parameter nIndexGroup in this case. In order to be able to evaluate the nIndexOffset, you must first use the AdsCreateVarHandle() method to fetch the handle of the ADS variable. This can be done, for instance, in the form's load event. In the event AdsReadConnectUpdate() it is then queried which variable handle was transferred in the parameter nIndexOffset.
If the connection was not created with the variable name, but with the variable address, then in the parameters nIndexGroup and nIndexOffset the address of the variable is transferred, which has changed.
If the connection between VB variable and ADS variable is terminated, also the handle should be released again with the method AdsDeleteVarHandle().
Example
-