0% found this document useful (0 votes)
53 views12 pages

Electro-Team: Interesting Education Visual Basic 2010 Timers

The document discusses using timers in Visual Basic 2010 to create simple animations and clocks. It provides multiple code examples of using timers to change label colors, move labels around the form, and display the current time. The code demonstrates how to toggle timers on and off to create sequential animations and prevent timers from running simultaneously.

Uploaded by

Mohamad Saad
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views12 pages

Electro-Team: Interesting Education Visual Basic 2010 Timers

The document discusses using timers in Visual Basic 2010 to create simple animations and clocks. It provides multiple code examples of using timers to change label colors, move labels around the form, and display the current time. The code demonstrates how to toggle timers on and off to create sequential animations and prevent timers from running simultaneously.

Uploaded by

Mohamad Saad
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Electro-Team

Interesting Education Visual Basic 2010 Timers

[email protected]

Open New Project

Windows Forms Application

Add Label & Button from Toolbox

Double Click on timer1:


Private Sub Timer1_Tick Label1.ForeColor = Color.Red End Sub

Double Click on Button1:


Private Sub Button1_Click
Timer1.Interval = 1000 Timer1.Enabled = True

End Sub

Run Time

Add another Timer to your form and make some changes to the previous code
Private Sub Timer1_Tick Label1.ForeColor = Color.Red Timer2.Enabled = True Timer1.Enabled = False End Sub
Private Sub Button1_Click Timer1.Enabled = True Timer1.Interval = 1000 Timer2.Interval = 1000 End Sub Private Sub Timer2_Tick Label1.ForeColor = Color.Black Timer1.Enabled = True Timer2.Enabled = False End Sub

Another Example:
Private Sub Timer1_Tick Label1.Left = Label1.Left + 10 Timer2.Enabled = True Timer1.Enabled = False End Sub Private Sub Button1_Click Timer1.Enabled = True End Sub Private Sub Timer2_Tick Label1.Top = Label1.Top + 10 Timer1.Enabled = True Timer2.Enabled = False End Sub

Clock
Private Sub Timer1_Tick
Label1.Text = TimeOfDay

End Sub Private Sub Button1_Click


Timer1.Enabled = True

End Sub

Moving Text
Dim temp As String Dim i As Integer Private Sub Timer1_Tick If i > Len(Label1.Text) Then Exit Sub i = i + 1 temp = Mid(Label1.Text, i, 1) Timer2.Enabled = True Timer1.Enabled = False End Sub Private Sub Button1_Click Timer2.Enabled = True Label2.BackColor = Color.Yellow End Sub Private Sub Timer2_Tick Label2.Text = Label2.Text + temp Timer2.Enabled = False Timer1.Enabled = True End Sub

The End
Produced by

Electro-Team
[email protected]

You might also like