Library code snippets

Rotate Colours

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)

Comments

  1. 01 Jan 1999 at 00:00

    This thread is for discussions of Rotate Colours.

Leave a comment

Sign in or Join us (it's free).

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

Related discussion

Related podcasts

  • Christian Beauclair

    14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss...

Want to stay in touch with what's going on? Follow us on twitter!