In Visual Basic 6.0, colors were represented by a Long data type value but in VB.NET, colors are objects like everything else. You can use the FromOle and ToOle methods to translates VB.NET Color objects to and from the Long data type.
~~~~~~~~~~~~~~~~~~~~~~~~~
Dim myColor As Color
Dim oleColor As Integer
myColor = ColorDialog1.Color
oleColor = ColorTranslator.ToOle(myColor)
~~~~~~~~~~~~~~~~~~~~~~~~~
Although it's VB 6, you might enjoy reading about how these numbers could be manipulated and calculated in the About Visual Basic article Calculating a Contrasting Color Code.
But wait! There's More!
VB.NET adds a whole new feature called the alpha component. Alpha lets you create transparent graphics! If you want to specify an alpha component, use the Color.FromArgb method and add a new argument ranging from 0 to 255 in front of the RGB numbers.
~~~~~~~~~~~~~~~~~~~~~~~~~
Dim myColor as Color myColor = Color.FromArgb(127, 23, 56, 78)
~~~~~~~~~~~~~~~~~~~~~~~~~
Just as we save desert for the end of the meal, the completed version of the Music Trivia program we started in Chapter 1 is presented at the end of this lesson on the next page ...


