AddItems method
Description | Creates OPCItem objects and adds them to the OPCItems collection. The properties of each new OPCItem are determined by the current defaults in the given OPCItems object. After an OPCItem is added, its properties can also be modified. |
Syntax | AddItems (Count As Long, ItemIDs() As String, ClientHandles() As Long, ByRef ServerHandles() As Long, ByRef Errors() As Long, Optional RequestedDataTypes As Variant, Optional AccessPaths As Variant)Count — Number of items to be added.ItemIDs — String array containing ItemID's.ClientHandles — Array of user-specified item handles for identifying data returned in callback functions.ServerHandles — Array of server specified item handles for the items processed.Errors — Array of values indicating the success/failure of the individual items operation.RequestedDataTypes (Optional) — Variant containing an integer array of Requested DataTypes.AccessPaths (Optional) — Variant containing a string array of Access Path's. This value is not necessary if fully qualified ItemIDs are defined. |
Example | Dim arItemIDs() As String Dim arClientHandles() As Long Dim arServerHandles() As Long Dim arErrors() As Long Dim i As Long Dim lIndex As Long Dim MyOPCItem As RSLinxOPCAutomation.OPCItem ' Redim arrays to maximum possible size ReDim arItemIDs(1 To 4) ReDim arClientHandles(1 To 4) For i = 0 To 3 '/* Build array of itemIDs by combining Topic and Item specification arItemIDs(lIndex) = "[" & txtTopic(i) & "]" & txtItem(i) arClientHandles(lIndex) = i Next 'i '/* Add new items to MyOPCGroup MyOPCGroup.OPCItems.AddItems lIndex, arItemIDs, arClientHandles, arServerHandles, arErrors '/* Check for errors For i = LBound(arErrors) To UBound(arErrors) If arErrors(i) <> 0 Then txtStatus = MyOPCServer.GetErrorString(arErrors(i)) End If Next 'i |
Provide Feedback