Hello VBAers -
I am a VBA noob, so be patient.
I have an RS-232 device hooked up to my Win7 Excel 2010 spreadsheet leveraging the CommRead() and CommWrite() VBA functions I found on the web. The communication link works -- I can send VBA "Strings" of hex bytes to and from the device with my spreadsheet when "Buttons" are pressed.
The replies from our device come in as VBA "Strings" 4 hex bytes long.
So when the device sends me a 32 bit integer 1234567 decimal my VBA function gets a "String" of 4 non-printable hex bytes: 0x00 0x12 0xD6 and 0x87, which is 1234567 decimal.
I seek a VBA way to convert these bytes to the VBA "Long" integer.
Lots of VBA functions on the web appear to come close, but when I run them errors about Type Conversion incompatibility pop up. Some functions use Byte Arrays but I don't get how to convert from String to Byte Arrays with VBA.
Therefore, VBA tips to convert such a hex byte String to a Long would be appreciated.
Thanks in advance!
Viper
I am a VBA noob, so be patient.
I have an RS-232 device hooked up to my Win7 Excel 2010 spreadsheet leveraging the CommRead() and CommWrite() VBA functions I found on the web. The communication link works -- I can send VBA "Strings" of hex bytes to and from the device with my spreadsheet when "Buttons" are pressed.
The replies from our device come in as VBA "Strings" 4 hex bytes long.
So when the device sends me a 32 bit integer 1234567 decimal my VBA function gets a "String" of 4 non-printable hex bytes: 0x00 0x12 0xD6 and 0x87, which is 1234567 decimal.
I seek a VBA way to convert these bytes to the VBA "Long" integer.
Lots of VBA functions on the web appear to come close, but when I run them errors about Type Conversion incompatibility pop up. Some functions use Byte Arrays but I don't get how to convert from String to Byte Arrays with VBA.
Therefore, VBA tips to convert such a hex byte String to a Long would be appreciated.
Thanks in advance!
Viper