Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Visual Studio
Visual Basic
Functions
M-R Functions
 RGB Function

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
Visual Basic Language Reference 
RGB Function (Visual Basic) 

Returns an Integer value representing an RGB color value from a set of red, green and blue color components.

RGB( _
      Red As Integer, _
    Green As Integer, _
      Blue As Integer _
)

Parameters

Red

Required. Integer in the range 0–255, inclusive, that represents the intensity of the red component of the color.

Green

Required. Integer in the range 0–255, inclusive, that represents the intensity of the green component of the color.

Blue

Required. Integer in the range 0–255, inclusive, that represents the intensity of the blue component of the color.

Exception type Error number Condition

ArgumentException

5

Green, Blue, or Red outside of range 0 and 255, inclusive.

See the "Error number" column if you are upgrading Visual Basic 6.0 applications that use unstructured error handling. (You can compare the error number against the Number Property (Err Object).) However, when possible, you should consider replacing such error control with Structured Exception Handling Overview for Visual Basic.

Application methods and properties that accept a color specification expect that specification to be a number representing an RGB color value. An RGB color value specifies the relative intensity of red, green, and blue to cause a specific color to be displayed.

If the value for any argument to RGB is greater than 255, 255 is used.

The following table lists some standard colors and the red, green, and blue values they include.

Color Red value Green value Blue value

Black

0

0

0

Blue

0

0

255

Green

0

255

0

Cyan

0

255

255

Red

255

0

0

Magenta

255

0

255

Yellow

255

255

0

White

255

255

255

This example shows how the RGB function is used to return a whole number representing an RGB color value.

Visual Basic
Dim red, rgbValue As Integer
Dim i As Integer = 75
' Return the value for red.
red = RGB(255, 0, 0)
' Same as RGB(75, 139, 203).
rgbValue = RGB(i, 64 + i, 128 + i)

Namespace: Microsoft.VisualBasic

Module: Information

Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker