Modbus in VB

K

Thread Starter

killua

please kindly help how to make a VB can read a modbus? for example I want to make a VB which can read modbus parameter 40001 from my devices..

and how to make a VB can read TCP/IP. with the same example.

Please help. send to my email: killua.control [at] yahoo.com

Thanks before.
 
> please kindly help how to make a VB can read a modbus? for example I want to >make a VB which can read modbus <

To handle binary data with a MSComm receiver is a tricky exercise of using bytes and variants. Here is a code snippet that worked for me.

Private bbuf(256) as byte
Private ByteCount as Integer

Private Sub MSComm1_OnComm()
Dim v As Variant
Dim b() As Byte

'ByteCount should be set to 0 for start of RX

Select Case MSComm1.CommEvent
Case comEvReceive
MSComm1.InputLen = 1
Do While MSComm1.InBufferCount > 0
v = MSComm1.Input
b = v
bbuf(ByteCount) = b(0)
ByteCount = ByteCount + 1
Loop
End Select
End Sub
 
Top