Search Tools Links Login

Get the seperate RGB values of a Colour

It turns the Decimal format of a colour value (example: 16777215) into three seperate values containing the seperate Red, Green, and Blue values. (example: red = 255, green = 255, blue = 255).

Original Author: Davy Cook


Input the colour that you wish to turn into its seperate RGB values. This should be in Decimal format.


Just make sure to keep the types as Long (&) because using an Integer (%) causes an overflow in the Red Value.


Returns the Red, Green, and Blue value from a colour.

Side Effects


API Declarations



Dim blue&, green&, red&, colour&
Blue& = Int(Colour& / 65536)
Green& = Int((Colour& - (65536 * Blue&)) / 256)
Red& = Colour& - (Blue& * 65536) - (Green& * 256)
'to return the colour to its original decimal format
Colour& = RGB(Red&, Green&, Blue&)

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 83 times


Visual Basic 6


No attachments for this post

Loading Comments ...


No comments have been added for this post.

You must be logged in to make a comment.