Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

RGB

3 views
Skip to first unread message

RABEA

unread,
Sep 12, 2007, 7:31:17 AM9/12/07
to
Hello All
Can Anyone Tell Me How Can I Get The RGP Color Format RGB(,,) For The
BackColor

For Example The BackColor For The Form Is 123456
What Is The RGB Equvalant To It

Thanks For All In Advanced


Douglas J. Steele

unread,
Sep 12, 2007, 6:47:43 AM9/12/07
to
Believe it or not, 123456 is RGB, but in the reverse order. If you convert
that value to Hex (01E240), the first 2 digits (Hex 01, or Decimal 1) are
the Blue value, the middle 2 digits (Hex E2, or decimal 226) are the Green
value and the last 2 digits (Hex 40, or Decimal 64) are the Red value.

Try the following will work:

Function Red(ColourValue As Long) As Long
Dim strHexColour As String

strHexColour = Right$("000000" & Hex(ColourValue), 6)
Red = CLng("&H" & Right$(strHexColour, 2))


End Function


Function Green(ColourValue As Long) As Long
Dim strHexColour As String


strHexColour = Right$("000000" & Hex(ColourValue), 6)
Green = CLng("&H" & Mid$(strHexColour, 3, 2))


End Function


Function Blue(ColourValue As Long) As Long
Dim strHexColour As String


strHexColour = Right$("000000" & Hex(ColourValue), 6)
Blue = CLng("&H" & Left$(strHexColour, 2))


End Function

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"RABEA" <ShamiJe...@Yahoo.com> wrote in message
news:uIwthgS9...@TK2MSFTNGP04.phx.gbl...

Jamie Collins

unread,
Sep 13, 2007, 8:30:14 AM9/13/07
to
On 12 Sep, 11:47, "Douglas J. Steele"

<NOSPAM_djsteele@NOSPAM_canada.com> wrote:
> If you convert
> that value to Hex (01E240), the first 2 digits (Hex 01, orDecimal1) are
> the Blue value
>
> Function Blue(ColourValue As Long) As Long
> Dim strHexColour As String
>
> strHexColour = Right$("000000" & Hex(ColourValue), 6)
> Blue = CLng("&H" & Left$(strHexColour, 2))
>
> End Function

You could use bit-wise operators:

Sub SplitRGB( _
ByVal RGBValue As Long, _
ByRef R As Long, _
ByRef G As Long, _
ByRef B As Long _
)
R = RGBValue And 255
G = RGBValue \ 256 And 255
B = RGBValue \ 256 ^ 2 And 255
End Sub

Jamie.

--


Pieter Wijnen

unread,
Sep 13, 2007, 6:47:17 PM9/13/07
to
Or
R = RGBValue And &HFF&
G = (RGBValue And &HFF00&) \ &H100&
B = (RGBValue And &HFF0000&) \ &H10000&

Pieter

"Jamie Collins" <jamiec...@xsmail.com> wrote in message
news:1189686614.1...@57g2000hsv.googlegroups.com...

Douglas J. Steele

unread,
Sep 25, 2007, 6:33:25 AM9/25/07
to
http://groups.google.com/group/microsoft.public.access/browse_frm/thread/5be1672d7faa98b5/0c642730348c235d#0c642730348c235d

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"RABEA" <ShamiJe...@Yahoo.com> wrote in message
news:uIwthgS9...@TK2MSFTNGP04.phx.gbl...

0 new messages