Link to home
Start Free TrialLog in
Avatar of sramesh2k
sramesh2kFlag for India

asked on

Convert CommonDialog.color to RGB format?

Hi,

Was just playing with the Common dialog box color picker. I noticed that it returns the color code in some other form rather than RGB.

Ex. Selecting 'Brown" color returned "4210816". Can I convert this value to RGB form?
Avatar of sramesh2k
sramesh2k
Flag of India image

ASKER

Now reading this doc: http://www.vb-helper.com/tut10.htm
ASKER CERTIFIED SOLUTION
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks. But VB does not seem to display the value in Long format. I selected the 1st color (reddish) and get this output : 8421631

Code:

cdlgColor.ShowColor
Text1.Text = cdlgColor.Color
Got this resolved: This function helped

----------------------------
Sub ConverttoRGB()
  R = C And 255              ' Get lowest 8 bits  - Red
  G = Int(C / 256) And 255   ' Get middle 8 bits  - Green
  B = Int(C / 65536) And 255 ' Get highest 8 bits - Blue
 
  out = R & "  " & G & "   " & B
End Sub

-----------------------------
http://www.freevbcode.com/ShowCode.asp?ID=1762