Archie
Sorry to bring this post back to life, but I have been trying to do the opposite, read a string (an array of characters indeed) using your WordsToString function from the PLC to the VB app.
So far I have not quite really understand how the function works, because I just get syntax errors.
Dim str(4) As String
'* Read it from the PLC
str = ModbusTCPCom1.Read("40009", str.Length)
Dim ResultString(4) As String
ResultString = MfgControl.AdvancedHMI.Drivers.Common.CalculationsAndConversions.WordsToString(str)
And I still have to figure how to pass the results to a string...
I made my own processing sub, but I want to understand and use the one you created, my code is still very basic and you need to know the lenght of the character array in the PLC by advance... see below:
Private Sub btnRead_Click(sender As Object, e As EventArgs) Handles btnRead.Click
Dim length As Integer = 6
Dim i As Integer = 0
Dim StartAddress As Integer
Dim Buffer As String = Nothing
While i < length
StartAddress = 40009 + i
val = ModbusTCPCom1.Read(StartAddress)
Dim BufferBytes As Byte() = BitConverter.GetBytes(val)
Dim SingleChar() As Char = {"", ""}
'From integer to ascii
SingleChar(0) = Chr(BufferBytes(1))
SingleChar(1) = Chr(BufferBytes(0))
Buffer = Buffer & SingleChar(0) & SingleChar(1)
i += 1
End While
tbxRead.Text = Buffer
End Sub