Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Solver gotchas G.R. Toro Excel Discussion (Misc queries) 4 February 7th 09 01:59 PM
Excel 2003 to 2007 Gotchas ... so I can be prepared Barb Reinhardt Excel Programming 2 April 29th 08 05:01 PM
Wildcards with numbers....* & ? not working the_superfly5 Excel Worksheet Functions 2 February 15th 08 08:43 PM
Text to Numbers NOT working BON Excel Discussion (Misc queries) 4 November 24th 06 11:39 AM
working with cells numbers mordor Excel Programming 2 May 31st 05 09:26 AM


All times are GMT +1. The time now is 10:40 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"