Databases Reference
In-Depth Information
Case 1
RGBCode = RGB(slvalue, Colors(ct, 2), Colors(ct, 3))
LabelRed = "Red Component: " & str(slvalue)
LabelGreen = "Green Component: " & str(Colors(ct, 2))
LabelBlue = "Blue Component: " & str(Colors(ct, 3))
Case 2
RGBCode = RGB(Colors(ct, 1), slvalue, Colors(ct, 3))
LabelRed = "Red Component: " & str(Colors(ct, 1))
LabelGreen = "Green Component: " & str(slvalue)
LabelBlue = "Blue Component: " & str(Colors(ct, 3))
Case 3
RGBCode = RGB(Colors(ct, 1), Colors(ct, 2), slvalue)
LabelRed = "Red Component: " & str(Colors(ct, 1))
LabelGreen = "Green Component: " & str(Colors(ct, 2))
LabelBlue = "Blue Component: " & str(slvalue)
End Select
'Display Color Using Label
Label_ColorTest.backcolor = RGBCode
frm5Morph.Repaint
Call Idle_Time (0.01)
Next sl
Next ct
End Sub
This subroutine is fairly straightforward. First, the number of color transitions (the variable
ct ) is determined by reading the indexes of the initial and final color selection Combo boxes. The
shading level of the appropriate RGB component must then be adjusted to create the next color in
the spectrum until the final color desired is reached. This is done in the second loop (the variable
sl ), and the shading level is denoted by the variable sl value that is adjusted up or down depending
upon what is required for the current transition. The RGB Code is then created utilizing a Select
Case statement that picks which RGB component is to be adjusted up or down. With each pass of
the sl loop, the RGB Code is updated, and the RGB parameters are updated in the form in real time.
Notice that each time the label is updated that displays the current color transition, the form
is repainted. This is necessary to ensure that the form does indeed display the current color assigned
to the label. Also notice that a delay is built into the looping structure. This ensures that the
transitions will not occur so quickly that the human eye cannot process them. The Idle_Time
subroutine pauses the macro for the number of seconds specified in the passed parameter nSecond .
It is important to note that, although the macro is pausing, background processes (such as repainting
forms) are allowed to continue. This is accomplished by means of the DoEvents function.
Public Sub Idle_Time(ByVal nSecond As Single)
Dim t0 As Single, tn As Single
Dim dummy As Integer, temp$
t0 = Timer
Do While Timer - t0 < nSecond
dummy = DoEvents()
'If we cross Midnight, back up one day
Search WWH ::




Custom Search