Question : Convert Hex to Dec from mscomm

I'm trying to convert from Hex to dec in VBA for access 97.

I am retrieving Hex values from an msComm control which I know are correct from analysing it using some serial monitoring software,

I want to extract the 2 red hex bytes from the below (returned by mscomm control, stored as a 9 byte string), swap them around and convert to a decimal, so:

40 E7 06 49 [I][COLOR=Red]E6 10[/COLOR][/I] 69 00 00

becomes:10 E6
which converts to decimal: 4326

Currently i'm using
[CODE]Private Sub Convert(hexString)
Dim intValue As Long
Dim hexSwap As String
' triggered by msComm receive event
' hexString from msComm buffer

hexSwap = (Mid(hexString, 5, 1)) & (Mid(hexString, 4, 1))
intValue = CLng("&H" & hexSwap)
MsgBox intValue

End Sub[/CODE]

which returns a type mismatch error.

In summary i wish to:
take 2 bytes of a received string,
swap their order,
concatenate them as 1 hex value,
convert that value to decimal.

If anyone can tell me where i'm going wrong i'd be very grateful

Cheers, Dan

Answer : Convert Hex to Dec from mscomm

This looks rather complex and not excatly what you are after but it does look related. It is the most hopeful bit I have found though.

http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q235856&
Random Solutions  
 
programming4us programming4us