Dear Crystal,
After running the code. I put "FFF200", It is supposed to be yellow, but it appears blue... The color is different from the one in the form property. Is there anything wrong?
Best Regards,
Kevin
hi Kevin,
BackColor will never be Null. BackStyle might be Transparent (0) -- Normal is 1.
You can also set Color using RGB (Red, Green, Blue) like this:
..BackColor = RGB( 255, 255, 255) 'white
To answer your question though, you can preface with &H and use CLng to convert to Long.
psHex is a string with a Hex code:
'~~~~~~~~~~~~~~~~~
Function GetDecFromHex(psHex As String) As Long
's4p
If InStr(psHex, "&H") = 0 Then
GetDecFromHex = CLng("&H" & psHex)
Else
GetDecFromHex = CLng(psHex)
End If
End Function
'~~~~~~~~~~~~~~~~~
have an awesome day,
crystal
On 3/8/2019 1:50 AM, Kevin qingqinga@yahoo.com [MS_Access_Professionals]
wrote:
> Dear All,
>
> Is it possible to convert color string into hex? So that I can apply it
> in code to customize the color of forms? Thanks in advance.
>
> I expect to get this result:
>
> Me.Color.BackColor=IIf(IsNull(Me.ColorCode),Color_Hex_To_Long("#FFFFFF"),Color_Hex_To_Long(Me.ColorCode))
>
>
> Best Regards,
>
> Kevin
>
>
>
> ------------------------------------
> Posted by: Kevin <qingqinga@yahoo.com>
> ------------------------------------
>
>
> ------------------------------------
>
> Yahoo Groups Links
>
>
>
Posted by: Kevin <qingqinga@yahoo.com>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (4) |
Tidak ada komentar:
Posting Komentar