AdsSyncWriteReq
Writes data of any type synchronously to an ADS device.
object.AdsSyncWriteReq(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 from which the data is written into the ADS variable
Return value
See ADS error codes
Comments
The execution of the Visual Basic program is stopped until the ADS device has received the data or until the time in the AdsAmsCommTimeout property 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 VBVarBoolean(0) As Boolean
VBVarInteger(0) = 123
VBVarLong(0) = 456
VBVarSingle(0) = 3,1415
VBVarDouble(0) = 2,876
VBVarByte(0) = 7
VBVarBoolean(0) = False
'Werte in SPS schreiben
Call AdsOcx1.AdsSyncWriteReq(&H4020&, 0&, 2&, VBVarInteger)
Call AdsOcx1.AdsSyncWriteReq(&H4020&, 2&, 4&, VBVarLong)
Call AdsOcx1.AdsSyncWriteReq(&H4020&, 6&, 4&, VBVarSingle)
Call AdsOcx1.AdsSyncWriteReq(&H4020&, 10&, 8&, VBVarDouble)
Call AdsOcx1.AdsSyncWriteReq(&H4020&, 18&, 1&, VBVarByte)
Call AdsOcx1.AdsSyncWriteReq(&H4021&, 152&, 2&, VBVarBoolean)