Discussion Locked

Colour Names

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

In Visual Basic is it possible to return colour names when a colour is chosen from colour pallete.
Lets say I want to allow the user to choose the colours and depending on his choice the colour names will be stored into a table created to store colour codes and names. I primarily want to store the colour names. Is it possible to do so? If yes then how do I do it?

7 replies

by seagull data services

As far as I know there is no built in function to return colour names
If you're selecting from a set pallette you will have predefined colour codes for the values for the colours and you could use a select case statement to return the colour name, e.g.
public function Colourname(colourcode as long) as string
select case (colourcode)
case vbRed
Colourname="Red"
.
.
etc
end select

A problem arises when you allow custom colours. Because the colour is defined by three 8 bit values for the Red, Green and Blue elements which comprise the colour, the range of numbers representing shades of a particular colour are not necessarily sequential.

I would suggest sticking to a particular set of colours consistent with the vb colour constants.

Hope this helps
John

by seagull data services

As DonQ notes below, Red, Blue and Yellow are the primary colours of the spectrum but monitors use Red, Green and Blue, as in the RGB function. In addition, printers (printing companies as opposed to what you print with from a PC) use a Cyan, Magenta, Yellow, Black combination to produce colour. This CYMK combination is also used in at least some colour photocopiers.

by donq

NO - colour is a combination "number" of the three basic clcours. See any one of the 3 object colour properties for an example.

This discussion is closed to new replies.