Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hello, I'm working with a form in V

Status
Not open for further replies.

Goodloe

Programmer
Sep 4, 2001
25
US
Hello, I'm working with a form in Visual Basic 6.

Based on the project I'm working with, I would like the form to change colors in a certain sequence.

The way it's currently set-up, the form changes colors at
random. I would like to be able to specify the the color
types and how many times the colors will rotate.

As you're responding to my request, can you provide some
sample code or the actual code that can be used to solve
my problem? Thanks

Oh, by the way, I'm using a Timer for the rotation.

 
I don't know if this is exactly what you wanted, but I think it will give you some ideas:

Dim arrColor(3) As OLE_COLOR
Dim intCurrent As Integer

Private Sub Form_Load()
arrColor(0) = vbBlue
arrColor(1) = vbRed
arrColor(2) = vbGreen
arrColor(3) = &H8080FF
End Sub

Private Sub Timer1_Timer()
Me.BackColor = arrColor(intCurrent)
If intCurrent < UBound(arrColor) Then
intCurrent = intCurrent + 1
Else
intCurrent = 0
End If
End Sub
 
Thank you very very much, the answer you gave was exactly
what I was looking for.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top