2 Colour Coding Questions :)

J

James

Hello I have the following code on a scrolling label...

--------------------------------------------------------
Dim Start As Object
Dim Start2 As Object

Start = lblChoice.ForeColor = RGB(0, 0, 0)
Start2 = lblChoice.ForeColor = RGB(255, 255, 255)

If Start Then
Start 1
ElseIf Start2 Then
Start2 -1
End If

Me.lblChoice.Caption = Mid$(Me.lblChoice.Caption, 2) & _
Left$(Me.lblChoice.Caption, 1)
---------------------------------------------------------

How do I make it so that the colours start from RGB
(0,0,0) then add one value to it rgb (1,0,0) etc. Then
when it reaches rgb(255,255,255) then it takes one away
and then goes the opposite way rgb (255,255,254) etc. then
go up and down all the time on a timer event?

Also I would like to ask another question related to the
above...

I have another startup form which I have a lable which I
want to draw attention to by doing this I wish the label
to flash 3 colours Red,Blue and Yellow... Again on a timer
event..

I have the code to change it from one color to the second
colour but then not including the third...

The code I have is:

--------------------------------------------------------
If lblStartUp1.ForeColor = RGB(255, 0, 0) Then
lblStartUp1.ForeColor = RGB(255, 255, 0)
ElseIf lblStartUp1.ForeColor = RGB(255, 255, 0) Then
lblStartUp1.ForeColor = RGB(255, 0, 0)
--------------------------------------------------------

How can I encorporate a third colour into this... I.E Blue
rgb (0,0,255)?

Thanks

James
 
D

Douglas J. Steele

For the first question, you can use variables in the RGB function:

While this isn't exactly what you'd want, it at least shows you how to cycle
through. (You want some way of changing one of the values in your Timer
event, not strictly in a loop)

Dim intRed As Integer
Dim intGreen As Integer
Dim intBlue As Integer

For intRed = 0 To 255
For intGreen = 0 To 255
For intBlue = 0 to 255
lblStartUp1.ForeColor = RGB(intRed, intGreen, intBlue)
Next intBlue
Next intGreen
Next intRed

For intRed = 255 To 0 Step -1
For intGreen = 255 To 0 Step -1
For intBlue = 255 to 0 Step -1
lblStartUp1.ForeColor = RGB(intRed, intGreen, intBlue)
Next intBlue
Next intGreen
Next intRed

For the second question,

Select Case lblStartUp1.ForeColor
Case RGB(255, 0, 0)
lblStartUp1.ForeColor = RGB(255, 255, 0)
Case RGB(255, 255, 0)
lblStartUp1.ForeColor = RGB(0, 0, 255)
Case Else
lblStartUp1.ForeColor = RGB(255, 0, 0)
End Select

BTW, I hope I never have to use any of your applications. Scrolling text and
flashing colours are not a particularly desirable interface!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top