AdsWrite[Datatype]Connect
AdsWriteBoolConnect
AdsWriteIntegerConnect
AdsWriteLongConnect
AdsWriteSingleConnect
AdsWriteDoubleConnect
Creates a fixed connection between a Visual Basic variable of type boolean, integer, long, single or double and a data item from an ADS device.
object.AdsWrite[Datatype]Connect(
nIndexGroupAs Long,
nIndexOffset As Long,
cbLength As Long,
nRefreshType As Integer,
nCycleTime As Integer,
pData As [Datatype]
) 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)
nRefreshType
[in] Type of data exchange between VB variable and ADS variable (see the ADSOCXTRANSMODE data type)
nCycleTime
[in] Write cycle in ms
pData
[in] Visual Basic variable from which the data is written into the ADS variable
Return value
See ADS error codes
Comments
If the connection to the ADS variable is no longer required, it should be released using the AdsWrite[Datatype]Disconnect() method. If only certain specific values are required in a form, the connection should only be created when the form is loaded, and should be released again when the form is closed.
Example
Dim VBVar As Integer
'wird beim Starten des Programms aufgerufen ---
Private Sub Form_Load()
'Verbindung zur Variable herstellen
Call AdsOcx1.AdsWriteIntegerConnect(&H4020&, 0&, 2&, 1, 110, VBVar)
End Sub
'wird beim Beenden des Programms aufgerufen
Private Sub Form_Unload(Cancel As Integer)
'Verbindung zu den Variablen in SPS beenden
Call AdsOcx1.AdsWriteIntegerDisconnect(VBVar)
End Sub
'wird durch den Bediener aufgerufen
Private Sub Cmd_write_Click()
VBVar = CInt(Text1.Text)
End Sub