Hey, I adjusted the code(see below)
Right now, it compiles without error but it gives the error: "The number of Operands to read cannot be less than 1" on
rw(0) = New ReadOperands
plc.ReadWrite(rw)
The complete code:
Dim rw() As ReadWriteRequest = New ReadWriteRequest((1) - 1) {}
rw(0) = New ReadOperands
plc.ReadWrite(rw)
Dim startRowIndex = Convert.ToInt16(CType(CType(rw(0), ReadOperands).ResponseValues, Object())(0))
table.Rows(startRowIndex).Cells(3).Fields(0).Value = DateTimePicker1.Text 'datum en tijd
table.Rows(startRowIndex).Cells(2).Fields(0).Value = lblvoerbaknr.Text
table.Rows(startRowIndex).Cells(0).Fields(0).Value = lblVoerzend.Text
table.Rows(startRowIndex).Cells(1).Fields(0).Value = lblzendgewicht.Text
' Now you increment startRowIndex by the number of rows you intend to write (in this example, only 1 row):
startRowIndex = (startRowIndex + 1)
' Now you write the table (You can also use Update, which will only update the cells that you have altered)
table.Write()
' or table.Update()
' Now we need to update the value of MI100 in the PLC.
'30-1-15 ANDERS dan bron! aangepast naar .net en code lichtelijk veranderd! Broncode:
Dim Write As WriteOperands = New WriteOperands()
rw(0) = Write
With Write
.NumberOfOperands = 1
.OperandType = OperandTypes.MI
.StartAddress = 100
.NumberOfOperands = 1
.Values = New Object() {startRowIndex}
End With
plc.ReadWrite(rw)