OLE_COLOR to R-G-B

 DevX Home Today's Headlines   Articles Archive   Tip Bank   Forums

# Thread: OLE_COLOR to R-G-B

1. Douglas Guest

## OLE_COLOR to R-G-B

Hi all,

Anyone got a sample of converting an OLE_COLOR into seperate R-G-B values?

Thanks,
Doug

2. Larry Rebich Guest

## Re: OLE_COLOR to R-G-B

Douglas,

Some months ago I wrote a tip of the month that I call 'Color Value
Conversions'. Link to http://www.buygold.net/tips.html then look for the
November 1998 tip of the month. A sample program is provided that shows how
to do the conversion...

Cheers,
Larry Rebich

"Douglas" <hot_n_cold_2000@hotmail.com> wrote in message
> Hi all,
>
> Anyone got a sample of converting an OLE_COLOR into seperate R-G-B values?
>
> Thanks,
> Doug
>
>

3. Rick Rothstein Guest

## Re: OLE_COLOR to R-G-B

Here is a general function to get any specified color part from a color
value:

Function RGorB(RGBvalue As Long, R_G_or_B As String) As Integer
Dim Exponent As Long
Exponent = InStr("RGB", UCase\$(Left\$(R_G_or_B, 1))) - 1
If Exponent = -1 Or RGBvalue < 0 Or RGBvalue > 16777216 Then
RGorB = -1
Else
RGorB = RGBvalue \ 256 ^ Exponent Mod 256
End If
End Function

where the first argument is the long color value (whole number as you call
it) and the second argument is "R", "G", or "B" depending on which color
value you want.

Rick

"Douglas" <hot_n_cold_2000@hotmail.com> wrote in message
> Hi all,
>
> Anyone got a sample of converting an OLE_COLOR into seperate R-G-B values?
>
> Thanks,
> Doug
>
>

4. Douglas Guest

## Re: OLE_COLOR to R-G-B

Thanks to both of you!

Doug

PS: I was calling it an OLE_COLOR, because that is the name used to declare
it as in:
Private m_Color As OLE_COLOR

"Rick Rothstein" <rick_newsgroup@email.com> wrote in message
news:393b32af\$1@news.devx.com...
> Here is a general function to get any specified color part from a color
> value:
>
> Function RGorB(RGBvalue As Long, R_G_or_B As String) As Integer
> Dim Exponent As Long
> Exponent = InStr("RGB", UCase\$(Left\$(R_G_or_B, 1))) - 1
> If Exponent = -1 Or RGBvalue < 0 Or RGBvalue > 16777216 Then
> RGorB = -1
> Else
> RGorB = RGBvalue \ 256 ^ Exponent Mod 256
> End If
> End Function
>
> where the first argument is the long color value (whole number as you call
> it) and the second argument is "R", "G", or "B" depending on which color
> value you want.
>
>
> Rick
>
>
>
> "Douglas" <hot_n_cold_2000@hotmail.com> wrote in message
> > Hi all,
> >
> > Anyone got a sample of converting an OLE_COLOR into seperate R-G-B

values?
> >
> > Thanks,
> > Doug
> >
> >

>
>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

 FAQ Latest Articles Java .NET XML Database Enterprise
 Questions? Contact us. C++ Web Development Wireless Latest Tips Open Source