AdsRead[Datatype]Req

AdsReadIntegerReq

AdsReadLongReq

AdsReadSingleReq

AdsReadDoubleReq

AdsReadStringReq

Issues a read request for a data item of type integer, long, single, double or string.

object.AdsRead[Datatype]Req(
  nInvokeId As Long,
  nIndexGroup As Long,
  nIndexOffset As Long,
  cbLength As Long
) As Long

Parameter

nInvokeId

[in] Job number for identification of the response

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)

Return value

See ADS error codes

Comments

Once a read request has been sent to the ADS device, execution of the Visual Basic program continues. As soon as the data is available, the ADS-OCX triggers the event function AdsRead[Datatype]Conf() with which the requested data is transmitted.
When the read request is sent, an identification number must be specified, which is later returned when the event function is called. This allows an assignment between Read-Request and the event function.
Note on the data type String: It should be noted that the length of the data 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 nInvokeId As Long
nInvokeId = 1
'Lesen von MW0 aus der SPS
Call AdsOcx1.AdsReadIntegerReq(nInvokeId, &H4020&, 0&, 4&)

Private Sub AdsOcx1_AdsReadIntegerConf(ByVal nInvokeId As Long, ByVal nResult As Long, ByVal cbLength As Long, pData As Integer)
    If (nInvokeId = 1) And (nResult = 0) Then 
    'Daten anzeigen
    Label1.Caption = pData 
    End If
End Sub
Dim nInvokeId As Long
nInvokeId = 1
'Lesen aus SPS
Call AdsOcx1.AdsReadStringReq(nInvokeId, &H4020&, 0&, 20&)

Private Sub AdsOcx1_AdsReadStringConf(ByVal nInvokeId As Long, ByVal nResult As Long, ByVal cbLength As Long, ByVal pData As String)
    If (nInvokeId = 1) And (nResult = 0) Then
    'Daten anzeigen
    Label1.Caption = pData
    End If
End Sub