by Davy Cook (2 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating:
(5 Votes)
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).
Inputs
Input the colour that you wish to turn into its seperate RGB values. This should be in Decimal format.
Assumes
Just make sure to keep the types as Long (&) because using an Integer (%) causes an overflow in the Red Value.
Code Returns
Returns the Red, Green, and Blue value from a colour.
Side Effects
'None.
API Declarations'None.
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&)