Minggu, 01 Desember 2013

RE: [MS_AccessPros] VBA Color

 

Bryan

 

One of our retired MVP members wrote a function to get what you want.

'=============================

'(a) Fn_HexRGBtoLong() - It converts the Hex string version of RGB as

'depicted for back color in property sheet in Access 2007 into long color value.

'

'(a) Fn_LongToHexRGB() - It converts long color value into Hex string version

'of RGB for back color as per property sheet in Access 2007.

'

'Note - Hex string version of RGB as depicted for back color in property

'sheet in Access 2007 does not represent a straight hexadecimal number. It is a 6

'character string where first two characters represent R, middle two G and last

'two B (RGB components of color value).

'

'Best wishes,

'A.D.Tejpal

'------------

 

' Fn_HexRGBtoLong()

'=============================

Function Fn_HexRGBtoLong(HexString _

As String) As Long

' Converts HexRGB color values of A2K7

' property sheet to long color values.

Dim Txt As String

 

Txt = IIf(Left(HexString, 1) = "#", _

Mid(HexString, 2), HexString)

Txt = Right("000000" & Txt, 6)

 

Fn_HexRGBtoLong = _

RGB(CLng("&H" & Left(Txt, 2)), _

CLng("&H" & Mid(Txt, 3, 2)), _

CLng("&H" & Right(Txt, 2)))

End Function

 

 

Regards,
Bill Mosca,
Founder, MS_Access_Professionals
That'll do IT http://thatlldoit.com
MS Access MVP
https://mvp.support.microsoft.com/profile=C4D9F5E7-BB03-4291-B816-64270730881E

My Nothing-to-do-with Access blog

http://wrmosca.wordpress.com

 

From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of Bryan
Sent: Thursday, November 28, 2013 6:49 AM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] VBA Color

 

 

Hello – have another question that I cannot find a clear answer on the web…..

In VBA, the color code is different than what is in the property box (ie property box color = #C67171 and vba = 7434694)

Is there a “simple” way to just use the property color when setting the backcolor or forecolor in VBA without doing a web search for a converter program each time?

I did find the sample:

Me!Control.Backcolor = Val("&H" & "FFFFFF")

But cannot get it to work

Thanks,

B

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (11)
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar