Thursday, 23 May 2013

Tutorial: Make Animated/Blinking Label in VB.NET using Timer in 5 Easy Steps

Make Animated/Blinking Label in VB.NET using Timer in 5 Easy Steps

Step 1: Add a Label.

Step 2: Add a Timer.

Step 3: Go to the Form_Load or the Load Event of the Form by double-clicking it then add the codes below. (Codes inside here will execute once the form was loaded.)
 Timer1.Start() Label1.ForeColor = Color.Red
Step 4: Go to the Timer1_Tick or the Tick Event of the Timer by double-clicking it then add the codes below. (Codes inside here will execute once the timer starts ticking.)

Timer1.Enabled = True
Timer1.Interval = 100  'Expressed as 0.1 second.You can change this on how fast you want your label to change its color.
       If Label1.ForeColor = Color.Red Then
            Label1.ForeColor = Color.Yellow
        ElseIf Label1.ForeColor = Color.Yellow Then
            Label1.ForeColor = Color.Blue
        ElseIf Label1.ForeColor = Color.Blue Then
            Label1.ForeColor = Color.Violet
        ElseIf Label1.ForeColor = Color.Violet Then
            Label1.ForeColor = Color.Red
        End If

Step 5: Run the program and see what happens.










If this post helped you please take a few seconds to share it! :)

2 comments: