View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Per Jessen Per Jessen is offline
external usenet poster
 
Posts: 1,533
Default working with Hex numbers.... A few gotchas I need help with...

Hi

Try this:

RtnStr = "'00" & t3

BTW: You should always tell us the desired result, for reference.

Regards,
Per

"Phillip" skrev i meddelelsen
...
I am working with Hex numbers in a worksheet
I have the numbers that are sent to me in the following formats:
0011E3637679:
0011E3CC7E0D:
0015CEE79A4B:
00189B1B8287:
0011E3A60085:

Each number for the MOST part, I have it working fine.

The problem occurs when the address is ONLY numbers (still a valid HEX)
Something like
001892080747:

and also an issue comes when I come across something that LOOKS like
SCIENTIFIC notation like:
0018920807E7:


Here is a sample of my code that I use:
'lngin is defined as column "b" & row() in a for next loop
lngin = teststr1
t1 = Right(lngin, 10) 'all of the hex do start with "00", so this
gives me the plain HEX num,
'with the 2 leading "00" removed as well as the ":" removed
t2 = Application.Hex2Dec(t1) + 1
t3 = Application.Dec2Hex(t2)
RtnStr = "'00" & Application.Text(t3, 999999999999#)

'Now to write the new number to a different column (defined as Tocol3 &
then the row - icount)
celname = tocol3 & Str(icount)
curcel2 = Application.Substitute(celname, " ", "")
Range(curcel2).Value = RtnStr

end of snipett

Sample:
001095180651 will return 00999999999999
0020407080E2 will return 00999999999999


Any suggestions?

Thanks
Phil