Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I get RGB values from ColorDialog selection ? 2

Status
Not open for further replies.

HarryMangurian

Technical User
Jan 17, 2005
2
US
I want to use the standard VB .NET ColorDialog control and then obtain the RGB components of the selected color.

Can this be done ?
 
Boy did you ask the right question on the right day!

The standard VB .NET ColorDialog control returns a color object, and to get the argb values, you use the Color.ToArgb Method.

This will return you the Alpha, Red, Green, and Blue values.
Or you can use Color.A, Color.R, Color.G, Color.B.

Do a search for Color object in the help.

Hope this helps...
 
Color.R etc. works like gangbusters. [2thumbsup]

Many thanks !!

A quick try at Color.toArgb did not work.
I am missing something in using that.
If I get time I will research it.
 
star for bigfoot


Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
It should work fine. I'll do a quick test project and let you know. I have not used it yet. I needed rgp to color and not the oppisit.
 
Try this and see if it's clearer.
Code:
Dim c As Color, i As Integer, k As Color

'Create a red color and assign to c
c = Color.Red

'Assign the color back to it's numeric value
i = c.ToArgb()

'Show the numeric value converted back to a color.
Debug.WriteLine(k.FromArgb(i))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top