AdsSyncReadReq

Reads data of any type synchronously from an ADS device.

object.AdsSyncReadReq(
  nIndexGroup As Long,
  nIndexOffset As Long,
  cbLength As Long,
  pData As YY
) As Long

Parameter

nIndexGroup

[in] Index group of the ADS variable

nIndexOffset

[in] Index offset of the ADS variable

cbLength

[in] Length of the data in bytes (see VB variable lengths)

pData

[in] Visual Basic variable into which the data is written from the ADS variable

Return value

See ADS error codes

Attention: In case of an error the VB variable (pData), whose value should be written, is set to "0".

Comment

The execution of the Visual Basic program is stopped until the data from the ADS device is available or until the time in the property AdsAmsCommTimeout is exceeded.
The Visual Basic variable must be declared as an array. The entire array is passed to the method.
The variable type string is not supported.

Example

Dim VBVarInteger(0) As Integer
Dim VBVarLong(0) As Long
Dim VBVarSingle(0) As Single
Dim VBVarDouble(0) As Double
Dim VBVarByte(0) As Byte
Dim VBVarBool(0) As Boolean

'Variablen auslesen
Call AdsOcx1.AdsSyncReadReq(&H4020&, 0&, 2&, VBVarInteger)
Call AdsOcx1.AdsSyncReadReq(&H4020&, 2&, 4&, VBVarLong)
Call AdsOcx1.AdsSyncReadReq(&H4020&, 6&, 4&, VBVarSingle)
Call AdsOcx1.AdsSyncReadReq(&H4020&, 10&, 8&, VBVarDouble)
Call AdsOcx1.AdsSyncReadReq(&H4020&, 18&, 1&, VBVarByte)
Call AdsOcx1.AdsSyncReadReq(&H4021&, 152&, 2&, VBVarBool)

'Variablen anzeigen
lblInteger.Caption = VBVarInteger(0)
lblLong.Caption = VBVarLong(0)
lblSingle.Caption = VBVarSingle(0)
lblDouble.Caption = VBVarDouble(0)
lblByte.Caption = VBVarByte(0)
lblBool.Caption = VBVarBool(0)