from the modbus in VB department...
Modbus in VB
Engineering and workplace issues. topic
Posted by killua on 22 October, 2009 - 4:45 am
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.


Posted by Harvard on 24 October, 2009 - 9:34 am
> 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

Your use of this site is subject to the terms and conditions set forth under Legal Notices and the Privacy Policy. Please read those terms and conditions carefully. Subject to the rights expressly reserved to others under Legal Notices, the content of this site and the compilation thereof is © 1999-2010 Nerds in Control, LLC. All rights reserved.

Users of this site are benefiting from open source technologies, including PHP, MySQL and Apache. Be happy.


Fortune
Indifference will be the downfall of mankind, but who cares?