sramesh2k
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?
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
Code:
cdlgColor.ShowColor
Text1.Text = cdlgColor.Color
ASKER
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
--------------------------
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
ASKER