Jump to content

Cannot write to datatable using VB.NET (V570) - UserInputException


Recommended Posts


We are using datatables in V570.

Trying to write to the first column in the first table in V570, address 0 – which is a Integer column.

I’m not able to write to it, I Just get an UserInputException (Invalid write values).

I’m able to read the same column, using the same addressing.

What’s wrong with my code?

Public Function WriteTableFeedPlan(ByVal FeedPlanId As Integer)

Dim rw() As ReadWriteRequest = New ReadWriteRequest(0) {}

Dim StartAddress As UInteger = 0

Dim NumberOfBytesToWriteInRow As UShort = 2

Dim NumberOfRowsToWrite As UShort = 1

Dim RowSizeInBytes As UShort = 2

Dim ValueList As New List(Of Byte)

Dim byte1 As Byte = 4

Dim byte2 As Byte = 5



rw(0) = New WriteDataTables(StartAddress, NumberOfBytesToWriteInRow, NumberOfBytesToWriteInRow, RowSizeInBytes, ValueList)






Return False

End Try

Return True

End Function

Link to comment
Share on other sites

Dear Fre_ZZe,

Ok, your code has a small bug. Instead of sending the number of rows to write, you send the number of bytes to write in row.

Therefore, you request to write 2 bytes * 2 rows, but supply only 2 bytes. Your code is:

rw(0) = New WriteDataTables(StartAddress, NumberOfBytesToWriteInRow,
, RowSizeInBytes, ValueList)

while it should have been:

rw(0) = New WriteDataTables(StartAddress, NumberOfBytesToWriteInRow,
, RowSizeInBytes, ValueList)

On the other hand, why working so hard and failing with such bugs. Why converting the integer value into 2 bytes? What would he do with strings and floats? Why not knowing the structure of the Data Tables and guessing its address?

I can suggest you to use our Unitronics.DataTables.dll, which makes things much easier.

You can read the structure and values of the data tables from the PLC, and also read and write specific cells.


The rar file contains both DLL and example.

The DLL uses the communication driver, but does all the hard work for you.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...