hex to decimal
Hi Keivn,
A possible way: Private Function HexToDec#(BinVal$) Dim i%, Lg% Lg = Len(BinVal) For i = Lg To 1 Step -1 HexToDec = HexToDec + (Nb(Mid(BinVal, i, 1)) * (16 ^ (Lg - i))) Next i End Function Private Function Nb%(i$) Const Chain$ = "0123456789ABCDEF" Nb = Val(InStr(1, Chain, i, 1) - 1) End Function Sub Test() ActiveCell = HexToDec(ActiveCell) End Sub MP "Keivn Green" a écrit dans le message de ... I need a macro that will convert a hex number to decimal. I've tried activecell= cdec(activecell) with no luck... I want to do it without having a formula in the cell do it. |
hex to decimal
yes Tom, good remark and very simple.
Regards, MP "Tom Ogilvy" a écrit dans le message de ... for less than 8 hexidecimal digits hexnumber = "A1B5" ActiveCell.Value = clng("&H" & hexnumber) -- Regards, Tom Ogilvy "Michel Pierron" wrote in message ... Hi Keivn, A possible way: Private Function HexToDec#(BinVal$) Dim i%, Lg% Lg = Len(BinVal) For i = Lg To 1 Step -1 HexToDec = HexToDec + (Nb(Mid(BinVal, i, 1)) * (16 ^ (Lg - i))) Next i End Function Private Function Nb%(i$) Const Chain$ = "0123456789ABCDEF" Nb = Val(InStr(1, Chain, i, 1) - 1) End Function Sub Test() ActiveCell = HexToDec(ActiveCell) End Sub MP "Keivn Green" a écrit dans le message de ... I need a macro that will convert a hex number to decimal. I've tried activecell= cdec(activecell) with no luck... I want to do it without having a formula in the cell do it. |
All times are GMT +1. The time now is 09:12 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com