Creating a blinking button in Visual Basic means adding a timer to your form. The blinking properties of the button are built into the timer, not the button itself. Including a timer in a form raises the possibility of using the timer to introduce other time-based functions to your VB program.
Add a button to your form. Drag a button object from the palette on the left hand side of the studio. If this is the first button on your form it will be called “Button1” by default.
Look down the Properties panel on the right of the screen. Find the “Text” property. This is the label that appears on your button. Change the button text to “Flashing” and click out of the field to automatically save the change.
Resize the button to make it bigger. For this exercise the button will be the only object on the form, so you might as well make it a significant size. You can also move the button to the centre of the form.
Drag a timer onto the studio from the palette on the left of the screen. It will be called “Timer1” by default.
Position the timer anywhere on the screen. It doesn’t have to be on the form or on the button.
Look through the properties of the timer. Find the “Interval” property and change its value to 50. Find the “Enabled” property and change this to “True” to make the timer active.
Add code to the Timer 1 “Tick” event. The code should read: Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles Timer1.Tick If Button1.Text = “Flashing” Then Button1.Text = “” ElseIf Button1.Text = “” Then Button1.Text = “Flashing” End If End Sub
Run the code by pressing the play button in the top menu bar. You will see the button appear with the text “Flashing” blinking on and off.