Example: Color Picker
In this section, you will develop a simple color
picker. The source code needed for this example is
stored in the "Source Code\Chapter21" directory. This
example uses three horizontal scrollbars. The Min
property value of all the scrollbars is set to 0 and
the Max property value is set to 255.
Option Explicit
Private Sub HSBlue_Change()
lblBlue.Caption = "Blue : "
& HSBlue.Value
lblColor.BackColor = RGB(HSRed.Value,
_ HSGreen.Value,HSBlue.Value)
End Sub
Private Sub HSGreen_Change()
lblGreen.Caption = "Green :
" & HSGreen.Value
lblColor.BackColor = RGB(HSRed.Value,
_
HSGreen.Value, HSBlue.Value)
End Sub
Private Sub HSRed_Change()
lblRed.Caption = "Red : "
& HSRed.Value
lblColor.BackColor = RGB(HSRed.Value,
_
HSGreen.Value, HSBlue.Value)
End Sub
Run the application and move the sliders, the color
shown by lblColor will change according to value of
the scrollbars.
The most important function used in this application
is the RGB function. The RGB function returns a Long
whole number representing an RGB color value.
RGB(red, green, blue)
The arguments red, green, blue, should be in the
range 0–255, inclusive.
|
|
Today's lesson explained how
easy it is to use the scrollbars in your applications.
Scroll bars provide easy navigation through
a long list of items or a large amount of information.
They can also provide an analog representation
of current position.
|
|