vaichidrewar
vaichidrewar

Reputation: 9621

how to get RGB numerical equivalent of color in vb.net

net there are many standard colors are available . But how to know there numerical value. I want those numerical values so that by changing those I can obtain the required shades which are not available as standard colors.

E.g for black we know numerical RGB equivalent is 0, 0, 0 But what are RGB values for olive color?

how to do this color name to numeric RGB value conversion

Upvotes: 4

Views: 28374

Answers (3)

user1390931
user1390931

Reputation: 53

Public Function Color2Integer(ByVal c As Color) As Integer
     Return c.ToArgb
End Function

Public Function Integer2Color(ByVal colorValue As Integer) As Color
    Return Color.FromArgb(colorValue)
End Function

Upvotes: 5

MusiGenesis
MusiGenesis

Reputation: 75396

The Color struct has .A, .R, .G and .B fields.

For example:

Dim color As Color = Color.Olive
Dim r As Integer = color.R
Dim g As Integer = color.G
Dim b As Integer = color.B

Upvotes: 7

Bobort
Bobort

Reputation: 3218

Since all of the colors are of the Color object, you simply need to instantiate the color and call the Color methods that you want to.

You probably want something like this:

Console.Write(Color.Olive.R & " " & Color.Olive.G & " " & Color.Olive.B)

Upvotes: 5

Related Questions