AdsSyncWrite[Datatype]Req
AdsSyncWriteBoolReq
AdsSyncWriteIntegerReq
AdsSyncWriteLongReq
AdsSyncWriteSingleReq
AdsSyncWriteDoubleReq
AdsSyncWriteStringReq
Writes data synchronously from a Visual Basic variable of type boolean, integer, long, single, double or string into a data item of an ADS device.
object.AdsSyncWrite[Datatype]Req(indexGroup As Long,
indexOffset As Long,
length As Long,
pData As [Datatype]
) As Long
Parameter
indexGroup
[in] Index group of the ADS variable
indexOffset
[in] Index offset of the ADS variable
length
[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 property AdsAmsCommTimeout is exceeded.
Note on the String data type: When considering the length of the data, note that it refers to the length of the variable in the Visual Basic program. Since Visual Basic represents a character with 2 bytes, the length of the variable must be determined with LenB(), not with Len().
Example
Dim VBVar As Boolean
VBVar = True
Call AdsOcx1.AdsSyncWriteBoolReq(&H4021&, 0&, 2&, VBVar)
Dim VBVar As String
VBVar = "TwinCAT"
Call AdsOcx1.AdsSyncWriteStringReq(&H4020&, 0&, LenB(VBVar), VBVar)