There are some algorithms on line if you want to convert
them to your purposes. Just Google "RGB Rainbow VBA" and
look through some of the real Rainbow shifting routines.
If you want something that still looks pretty gradual, but
is not the rainbow progression...
Option Compare Database
Option Explicit
Private miRed As Integer
Private miBlue As Integer
Private miGreen As Integer
Private mbFlipRed As Integer
Private mbFlipBlue As Integer
Private mbFlipGreen As Integer
Private Sub Form_Load()
Me.Detail.BackColor = 0
' I should have initialized everything! oh, well.
End Sub
Private Sub Form_Timer()
' Cycle through each of the RGB color values,
' each with a different periodicity. To keep
' from seeing jarring shifts, alternate directions.
' Also, the step values are prime and small in order
' to keep the total cycle long.
miRed = miRed + mbFlipRed * 2
If miRed <= 0 Then
mbFlipRed = 1
miRed = 0
End If
If miRed > 255 Then
mbFlipRed = -1
miRed = 255
End If
miGreen = miGreen + mbFlipGreen * 3
If miGreen <= 0 Then
mbFlipGreen = 1
miGreen = 0
End If
If miGreen > 255 Then
mbFlipGreen = -1
miGreen = 255
End If
miBlue = miBlue + mbFlipBlue * 5
If miBlue <= 0 Then
mbFlipBlue = 1
miBlue = 0
End If
If miBlue > 255 Then
mbFlipBlue = -1
miBlue = 255
End If
Me.Detail.BackColor = RGB(miRed, miGreen, miBlue)
End Sub
If this works for you, it's cheap, quick, and simple.
Kevin
John Ortt<Jo******@Idontwantspamsonoreturnaddress.com>
6/13/2005 8:37 AM >>>Thanks for the reply Tom,
I was just prob just getting my head round it as you were
writing your reply
:)
"Tom van Stiphout" <no*************@cox.net> wrote in
message
news:26********************************@4ax.com.. . On Mon, 13 Jun 2005 11:12:32 +0100, "John Ortt"
<Jo******@Idontwantspamsonoreturnaddress.com> wrote:
Set your timer to 10 msec and let it rip for a few
minutes. You'll see other colors appear. Don't expect a gradual transition.
Look at each individual RGB color that's generated, and you'll
understand why you won't have a perfect rainbow effect.
-Tom.