Thanks for the response Godra, I did read both of those before posting and they didn't quite fit what I was trying to do.
There are many examples of reading individual bits or values of complete registers. This application requires reading the value of the first 5 bits and the value of the next 19 bits both as integers spread across 2 16bit registers.
The only way I could figure out how to do it was with bitwise operators.
There are 40 event registers so I just duplicated this code and changed the register address and the event numbers.
Here is the code I came up with:
Private Event1 As Integer
Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Event1 = ModbusTCPCom1.Subscribe("L41511", 1, 500, AddressOf Event1_Data_Received)
End Sub
Private Sub Event1_Data_Received(sender As Object, e As Drivers.Common.PlcComEventArgs)
Dim code, FMI, SPN As Integer
If e.ErrorId = 0 AndAlso e.Values IsNot Nothing AndAlso e.Values.Count > 0 Then
code = e.Values(0) And 16777184
SPN = code >> 5
FMI = e.Values(0) And 31
End If
Label1.Text = "SPN " & SPN & "_" & "FMI " & FMI
End Sub