ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   hex2dec (https://www.excelbanter.com/excel-programming/354783-hex2dec.html)

jgreen

hex2dec
 
I would like to know how to convert a hex2dec string value in excel 2003

ex of string value: FFFB: 00FFB125148

I only want to convert values starting at the 7th charactor ending at the
14th.(00FFB125),

RB Smissaert

hex2dec
 
This is a function I use for that:

Function Hex2Dec(strHex As String) As Long

'converts a hexadecimal number to a long
'if the prefix &H is not there, it will be added first
'-----------------------------------------------------

On Error GoTo ERROROUT

If Left$(strHex, 2) = "&H" Then
Hex2Dec = CLng(Val(strHex))
Else
Hex2Dec = CLng(Val("&H" & strHex))
End If

Exit Function
ERROROUT:

MsgBox "CAN'T HANDLE THE STRING: " & strHex, , "Hex2Dec"

End Function

You could then do:
MsgBox Hex2Dec(Mid$("FFFB: 00FFB125148", 7, 8))


RBS



"jgreen" <u19247@uwe wrote in message news:5c9ed809cbdcb@uwe...
I would like to know how to convert a hex2dec string value in excel 2003

ex of string value: FFFB: 00FFB125148

I only want to convert values starting at the 7th charactor ending at the
14th.(00FFB125),



All times are GMT +1. The time now is 10:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com