Hello all,
I am trying to make an application, that gets data from OPC server to form1 and displays some pieces in form2. The app works that way: on start - form1 starts. Form2 must be started manually after form form1 is statrted (i mad a buttton for that). If some values in OPC server changes i need to see some of them in form2. Here is a sub which shows how do i get data from OPC server.
Code:
Public mObject As List (Of Object)
Overridable Sub OnDataChange( _
ByVal dwTransid As Integer, _
ByVal hGroup As Integer, _
ByVal hrMasterquality As Integer, _
ByVal hrMastererror As Integer, _
ByVal dwCount As Integer, _
ByVal phClientItems() As Integer, _
ByVal pvValues() As Object, _
ByVal pwQualities() As Short, _
ByVal pftTimeStamps() As OpcRcw.Da.FILETIME, _
ByVal pErrors() As Integer) Implements IOPCDataCallback.OnDataChange
Dim i As Integer = 0
Dim j As Integer = 1
Dim k As Integer = 0
If dwCount > 0 Then
mObject = New List(Of Object)
For i = 0 To jk - 1
For j = 1 To jk
If phClientItems(i) = j Then
mObject.Add(pvValues(k))
k += 1
End If
Next j
Next i
End If
dwCount = 0
End Sub
I have tried to write line before sub end
Code:
Dim c As Integer
For c=0 To mObject.Count - 1
Form2.mObject.Add(Object(c))
Next c
but nothing happened when i opened form2, nor on change of data in OPC server (i wrote the code that on form2 load all values are shown in msgbox, message box did not show up).
dwCounts - how many values were changed in PLC.
phClientItems - variable index.
pvValues - variable value.
All the ideas are wellcome.
Thank you in advance.