Help!! to read remote meters using LAN in VB6.0


Thread Starter


I am trying to implement remote metering using socket in vb 6.0 from different IPs of LAN. But the problem is in some cases getting negative value for big readings. In some cases results are abnormal.

I have used SerialServer(HMS) modbus RTU and L&T meters with RS 485.
Pl help me.

Otherwise advice for better program in VB6.0 or other.

Lynn August Linse

Older Visual Basic (& Python & many 'modern' human-oriented languages) lack the notion of 'unsigned integer'.

So by default, if you convert a 16-bit integer to VB, you'll see -32768 to 32767. This is problem if 0xFFFF means 65,535 and NOT -1.

You should do some Google/Bing research on importing data into VB. Since the Modbus message really comes in as a binary string, you probably have to manually convert the 2 (or 4) bytes into an Integer if 16-bit/2-byte as the VB Integer is signed 32-bit, or Long if 32-bit/4-byte as the VB Long Integer is signed 64-bit.

Now I think around VS 2005 they introduced the types of UInteger and ULong, but you are safer to use normal Integer & Long since not all VB add ons will be expecting unsigned data.