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?
LVL 34
sramesh2kAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sramesh2kAuthor Commented:
Now reading this doc: http://www.vb-helper.com/tut10.htm
0
DhaestCommented:
Public Function ColorCodeToRGB(lColorCode As Long, iRed As Integer, iGreen As Integer, iBlue As Integer) As Boolean
' 1996/01/16 Return the individual colors for lColorCode.
' 1996/07/15 Use Tip 171: Determining RGB Color Values, MSDN July 1996.
' Enter with:
'     lColorCode contains the color to be converted
'
' Return:
'     iRed    contains the red component
'     iGreen  the green component
'     iBlue   the blue component
'
    Dim lColor As Long
    lColor = lColorCode      'work long
    iRed = lColor Mod &H100  'get red component
    lColor = lColor \ &H100  'divide
    iGreen = lColor Mod &H100 'get green component
    lColor = lColor \ &H100  'divide
    iBlue = lColor Mod &H100 'get blue component

    ColorCodeToRGB = True
End Function

Source: http://www.buygold.net/v02n04/v02n04.html
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sramesh2kAuthor Commented:
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
0
sramesh2kAuthor Commented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.