Home > How-To Library > Miscellaneous

How to Convert OLE colors to RGB colors

**************************************************************** * © 2007 CodeItBetter http://www.codeitbetter.com * * This notice MUST stay intact for legal use * ****************************************************************
'convert colors like &H00C0C000& to RGB values Private Declare Function TranslateColor Lib "olepro32.dll" Alias "OleTranslateColor" (ByVal clr As OLE_COLOR, _ ByVal palet As Long, col As Long) As Long Private Sub Form_Load() Dim RealColor As Long 'Convert OLE colors to RGB colors TranslateColor Me.BackColor, 0, RealColor 'show the result MsgBox "The backcolor of this form is R=" & CStr(RealColor And &HFF&) & " G=" & _ CStr((RealColor And &HFF00&) / 2 ^ 8) & " B=" & CStr((RealColor And &HFF0000) / 2 ^ 16) End Sub

If you would like to submit your code here please us. Do not forget to mention your name. We are always thankful to each and everyone of you who submitted their code here.