Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Hexadecimal Woes

I'm working with coloring some reports and have been trying to define
colors (via enum) for them.

1) Why is it that RGB(a,b,c) ends up being in BGR order as HEX?
Example:
&H996633 = 10053171
RGB(153,102,51) = 3368601
RGB(51,102,153) = 10053171

2) Why is it that &HCCFF appears to be (what I think is) the two's
compliment to 0xCCFF?
&HCCFF = -13057
-13057 = -0x3301
0x3301 + 0xCCFF = 0x10000

I've got the color issues for my program figured out, I'm just curious
about why Excel behaves this way. I did a quick Google search that
didn't bring up any complaints about this, so I figure I must not be
understanding How Things Work correctly. Thanks for any insight you
can offer!

-Bryan

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Hexadecimal Woes

http://www.mvps.org/dmcritchie/excel/colors.htm

--
Regards,
Tom Ogilvy


"Bryan Loeper" wrote:

I'm working with coloring some reports and have been trying to define
colors (via enum) for them.

1) Why is it that RGB(a,b,c) ends up being in BGR order as HEX?
Example:
&H996633 = 10053171
RGB(153,102,51) = 3368601
RGB(51,102,153) = 10053171

2) Why is it that &HCCFF appears to be (what I think is) the two's
compliment to 0xCCFF?
&HCCFF = -13057
-13057 = -0x3301
0x3301 + 0xCCFF = 0x10000

I've got the color issues for my program figured out, I'm just curious
about why Excel behaves this way. I did a quick Google search that
didn't bring up any complaints about this, so I figure I must not be
understanding How Things Work correctly. Thanks for any insight you
can offer!

-Bryan


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Hexadecimal Woes

While a good resource for color, that page doesn't really answer
either of my questions.

On May 18, 2:50 pm, Tom Ogilvy
wrote:
http://www.mvps.org/dmcritchie/excel/colors.htm

--
Regards,
Tom Ogilvy


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Hexadecimal Woes

1. Each RGB value occupies a byte (0-255). In VB/A RGB values are placed in
order least to most significant byte:-

&Hbbggrr

In many languages, perhaps the majority, the byte order is reversed.
Strangely, some API's use RGB and others BRG.

2. I don't really understand what the question is, and why you are only
dealing with two of the three RGB bytes.
But, whatever it is, perhaps your confusion might relate to your mixing
Integer Hex (2 byte) and Long Hex (4 byte) values

&HCCFF = -13057

values 0 to &H7FFF are +ve, 0 to 32767
values &H8000 to &HFFFF are -ve, -32768 to -1

to coerce to a Long add the &
&HCCFF& = 52479 = rgb(255,204,000)

Regards,
Peter T



"Bryan Loeper" wrote in message
ups.com...
I'm working with coloring some reports and have been trying to define
colors (via enum) for them.

1) Why is it that RGB(a,b,c) ends up being in BGR order as HEX?
Example:
&H996633 = 10053171
RGB(153,102,51) = 3368601
RGB(51,102,153) = 10053171

2) Why is it that &HCCFF appears to be (what I think is) the two's
compliment to 0xCCFF?
&HCCFF = -13057
-13057 = -0x3301
0x3301 + 0xCCFF = 0x10000

I've got the color issues for my program figured out, I'm just curious
about why Excel behaves this way. I did a quick Google search that
didn't bring up any complaints about this, so I figure I must not be
understanding How Things Work correctly. Thanks for any insight you
can offer!

-Bryan



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Hexadecimal Woes

Ok, I think I understand number 1 as far as theory goes. As for
number 2, whenever I put in &H00CCFF, it always gets shortened to
&HCCFF. Thanks for the clarification about the second '&'! It was
exactly what I was looking for.

-Bryan


On May 19, 6:39 pm, "Peter T" <peter_t@discussions wrote:
1. Each RGB value occupies a byte (0-255). In VB/A RGB values are placed in
order least to most significant byte:-

&Hbbggrr

In many languages, perhaps the majority, the byte order is reversed.
Strangely, some API's use RGB and others BRG.

2. I don't really understand what the question is, and why you are only
dealing with two of the three RGB bytes.
But, whatever it is, perhaps your confusion might relate to your mixing
Integer Hex (2 byte) and Long Hex (4 byte) values

&HCCFF = -13057

values 0 to &H7FFF are +ve, 0 to 32767
values &H8000 to &HFFFF are -ve, -32768 to -1

to coerce to a Long add the &
&HCCFF& = 52479 = rgb(255,204,000)

Regards,
Peter T

"Bryan Loeper" wrote in message

ups.com...



I'm working with coloring some reports and have been trying to define
colors (via enum) for them.


1) Why is it that RGB(a,b,c) ends up being in BGR order as HEX?
Example:
&H996633 = 10053171
RGB(153,102,51) = 3368601
RGB(51,102,153) = 10053171


2) Why is it that &HCCFF appears to be (what I think is) the two's
compliment to 0xCCFF?
&HCCFF = -13057
-13057 = -0x3301
0x3301 + 0xCCFF = 0x10000


I've got the color issues for my program figured out, I'm just curious
about why Excel behaves this way. I did a quick Google search that
didn't bring up any complaints about this, so I figure I must not be
understanding How Things Work correctly. Thanks for any insight you
can offer!


-Bryan- Hide quoted text -


- Show quoted text -



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
Import hexadecimal data into excel keeping hexadecimal format Whale Excel Discussion (Misc queries) 1 February 24th 10 08:23 AM
Hexadecimal data Marvin Buzz Excel Discussion (Misc queries) 2 September 4th 08 02:26 PM
Leading Zero in Hexadecimal? Tony Excel Discussion (Misc queries) 5 August 21st 07 03:32 AM
Decimal to Hexadecimal Sean Timmons Excel Discussion (Misc queries) 6 January 5th 07 10:45 PM
Hexadecimal to binary [email protected] Excel Discussion (Misc queries) 5 March 4th 06 05:45 PM


All times are GMT +1. The time now is 03: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"