Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 10,461 times

Related Categories

Rotate Colours

liserdarts

This code smoothly rotates the colour of a picture box. Create a form and add a timer and a picture box name the picture box pic. Then add this code to the timer and watch the color rotate. Don’t forget to give an interval to the timer.

Static Red As Integer
Static Green As Integer
Static Blue As Integer
Static Color As Byte
Static Dir As Boolean
   Randomize
   If Rnd < 0.05 Then
       Color = Int(3 * Rnd)
   End If
   Select Case Color
   Case 0
       If Red > 240 Then
           Dir = False
       ElseIf Red < 15 Then
           Dir = True
       End If
       If Dir = True Then
           Red = Red + 10
       Else
           Red = Red - 10
       End If
   Case 1
       If Green > 240 Then
           Dir = False
       ElseIf Green < 15 Then
           Dir = True
       End If
       If Dir = True Then
           Green = Green + 10
       Else
           Green = Green - 10
       End If
   Case 2
       If Blue > 240 Then
           Dir = False
       ElseIf Blue < 15 Then
           Dir = True
       End If
       If Dir = True Then
           Blue = Blue + 10
       Else
           Blue = Blue - 10
       End If
   End Select
   Pic.BackColor = RGB(Red, Green, Blue)

I am as a web developer for a small company, working for a small company. I work on banking websites and verious related projects.

by: Nick Avery liserdarts@yahoo.com

Comments