AsyncWrite method
Description | Write one or more items in a group. The results are returned via the AsyncWriteComplete event associated with the OPCGroup object. |
Syntax | AsyncWrite (NumItems As Long, ServerHandles() As Long, Values() As Variant, ByRef Errors() As Long, TransactionID As Long, ByRef CancelID As Long)NumItems — Number of items to be written.ServerHandles — Array containing server handles for the items to be written. Values — Array of values.Errors — Variant containing an integer array of errors indicating the success/failure of the individual items to be written.TransactionID — The client specified transaction ID. This is included in the 'completion' information provided in the AsyncWriteComplete Event.CancelID — A Server generated CancelID. This is provided to enable the client to cancel the transaction. |
Remarks | The AsyncWrite requires the OPCGroup object to have been dimensioned to handle events (Dim WithEvents MyOPCGroup As OPCGroup) in order for the results of the AsyncWrite operation to be returned to the client application. The AsyncWriteComplete event associated with the OPCGroup object will be called by the Data Access Server with the results of the AsyncWrite operation. |
Example | Dim lNumitems As Long Dim arData() As Variant Dim arHandles() As Long Dim arErrors() As Long Dim lTransID As Long Dim lCancelID As Long Dim i As Long '/* Specify number of elements lNumitems = MyOPCGroup.OPCItems.Count ReDim arHandles(1 To lNumitems) ReDim arData(1 To lNumitems) For i = 1 To lNumitems '/* Pass in the server handles arHandles(i) = MyOPCGroup.OPCItems(i).ServerHandle '/* Pass in the data arData(i) = txtData(MyOPCGroup.OPCItems(i).ClientHandle).Text Next 'i '/* Write the data to the server MyOPCGroup.AsyncWrite lNumitems, arHandles, arData, arErrors, lTransID, lCancelID '/* Check for errors For i = 1 To lNumitems If arErrors(i) > 0 Then txtStatus = MyOPCServer.GetErrorString(arErrors(i)) End If Next 'i |
Provide Feedback