Having some issues getting my code to add items to my collections in VB6. I have an OPC Topic called "PLC_1" with about 418 tags.. I need to only access a few of them.
On the RSView_Data is a primary Item RSView_Data with subitems that I need to access to read and write data to. My code works great up to where I need to start adding those sub items...
Not sure how to accomplish this... I thought I had a handle on groups,and Items etc...
Option Explicit
Option Base 1
Private WithEvents AnOPCServer As RsiOPCAutPCServer
Private WithEvents AnOPCGroup As RsiOPCAutPCGroup
Private WithEvents AnOPCGroups As RsiOPCAutPCGroups
Dim AnOPCItem As RsiOPCAutPCItem
Dim AnOPCItems As RsiOPCAutPCItems
Private Sub Form_Load()
Dim icount As Long
Dim sMsg As String
Dim dTime As Date
On Error GoTo ErrorHandler
'On Error Resume Next
Me.Caption = Me.Caption & " v" & App.Major & "." & App.Minor & " Build " & App.Revision
'Set server
Set AnOPCServer = New RsiOPCAutPCServer
AnOPCServer.Connect "RSLinx OPC Server", "PLC_1"
dTime = AnOPCServer.CurrentTime
Label1.Caption = dTime
'Set Groups
Set AnOPCGroup = AnOPCServer.OPCGroups.Add("PLC_1")
AnOPCGroup.OPCItems.De faultAccessPath = "PLC_1"
AnOPCGroup.UpdateRate = 100
AnOPCGroup.IsSubscribed = True
AnOPCGroup.OPCItems.DefaultIsActive = True
AnOPCGroup.OPCItems.AddItem "RSView_Data", 1
AnOPCGroup.OPCItems.AddItem "RSView_Status_Bits", 2
'Code works great up to this point.
' I need to add the items below RSView_Data to the AnOPCGroup.OPCItem "RSView_Data"
' Not sure how to accomplish this... I thought I had a handle on groups,and Items etc...
'This shows under RSView_Data in Tag Names under DataTable Monitor of RSLinx...
' RXView_Data (has the following sub items.)
'+ RSView_Data
' |- RSView_Data(0)
' |- RSView_Data(1)
' |- RSView_Data(2)
' etc etc...
icount = AnOPCServer.OPCGroups.Count
On the RSView_Data is a primary Item RSView_Data with subitems that I need to access to read and write data to. My code works great up to where I need to start adding those sub items...
Not sure how to accomplish this... I thought I had a handle on groups,and Items etc...
Option Explicit
Option Base 1
Private WithEvents AnOPCServer As RsiOPCAutPCServer
Private WithEvents AnOPCGroup As RsiOPCAutPCGroup
Private WithEvents AnOPCGroups As RsiOPCAutPCGroups
Dim AnOPCItem As RsiOPCAutPCItem
Dim AnOPCItems As RsiOPCAutPCItems
Private Sub Form_Load()
Dim icount As Long
Dim sMsg As String
Dim dTime As Date
On Error GoTo ErrorHandler
'On Error Resume Next
Me.Caption = Me.Caption & " v" & App.Major & "." & App.Minor & " Build " & App.Revision
'Set server
Set AnOPCServer = New RsiOPCAutPCServer
AnOPCServer.Connect "RSLinx OPC Server", "PLC_1"
dTime = AnOPCServer.CurrentTime
Label1.Caption = dTime
'Set Groups
Set AnOPCGroup = AnOPCServer.OPCGroups.Add("PLC_1")
AnOPCGroup.OPCItems.De faultAccessPath = "PLC_1"
AnOPCGroup.UpdateRate = 100
AnOPCGroup.IsSubscribed = True
AnOPCGroup.OPCItems.DefaultIsActive = True
AnOPCGroup.OPCItems.AddItem "RSView_Data", 1
AnOPCGroup.OPCItems.AddItem "RSView_Status_Bits", 2
'Code works great up to this point.
' I need to add the items below RSView_Data to the AnOPCGroup.OPCItem "RSView_Data"
' Not sure how to accomplish this... I thought I had a handle on groups,and Items etc...
'This shows under RSView_Data in Tag Names under DataTable Monitor of RSLinx...
' RXView_Data (has the following sub items.)
'+ RSView_Data
' |- RSView_Data(0)
' |- RSView_Data(1)
' |- RSView_Data(2)
' etc etc...
icount = AnOPCServer.OPCGroups.Count