Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
working with Hex numbers.... A few gotchas I need help with...
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
working with Hex numbers.... A few gotchas I need help with...
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Solver gotchas | Excel Discussion (Misc queries) | |||
Excel 2003 to 2007 Gotchas ... so I can be prepared | Excel Programming | |||
Wildcards with numbers....* & ? not working | Excel Worksheet Functions | |||
Text to Numbers NOT working | Excel Discussion (Misc queries) | |||
working with cells numbers | Excel Programming |