working with Hex numbers.... A few gotchas I need help with...

P

Phillip

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
 
P

Per Jessen

Hi

Try this:

RtnStr = "'00" & t3

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

Regards,
Per
 
P

Phillip

RtnStr = "'00" & t3
So simple! I guess the "Keep it simple stupid" rule applies! It makes sense
becuz t3 is dim as string! That was a carry over from some earlier trials...
It works!

BTW: You should always tell us the desired result, for reference.
I know this.... I should have

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top