devxlogo

Extract Red,Green,Blue components of a color

Extract Red,Green,Blue components of a color

If you have a 32-bit color value in RGB format, you can extract its Red, Green and Blue components using the following routines:

Function GetRed(ByVal lColor As Long) As Long    GetRed = lColor Mod 256End FunctionFunction GetGreen(ByVal lColor As Long) As Long    GetGreen = (lColor  &H100) Mod 256End FunctionFunction GetBlue(ByVal lColor As Long) As Long    GetBlue = (lColor  &H10000) Mod 256End Function

Remember that you can combine the red, green and blue components into a RGB color using the built-in RGB function

rgbColor = RGB(redColor, greenColor, blueColor)

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist