Building an Electronic Clock in VB.Net using timer class
(VB.NET ProgressBar using Timer)
Public Class Form1
Dim t As New Timer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
t.Interval = 1000
AddHandler t.Tick, AddressOf Me.t_ShowProgress
AddHandler t.Tick, AddressOf Me.t_ShowTime
t.Start()
End Sub
Private Sub t_ShowProgress()
ProgressBar1.Value += 10
If ProgressBar1.Value = 100 Then
ProgressBar1.Value = 0
End If
End Sub
Private Sub t_ShowTime()
Label1.Text = Now
End Sub
End Class
Add Handler - Associates an event with an event handler at run time. The Handles keyword and the AddHandler statement both allow you to specify that particular procedures handle particular events, but there are differences. The AddHandler statement connects procedures to events at run time. Use the Handles keyword when defining a procedure to specify that it handles a particular event.
The Tick event (this is similar to Visual Basic Timer1_Timer event) occurs when the specified timer interval has elapsed and the timer is enabled. This is based on the interval set for the Timer (1000 ms or 1 sec here)
The progress bar will be reset after it reaches 100. The timer will run till the form is closed. Since the process is synchronous only the timer event will be executed or the label will be updated. The same can also be achieved async
thank
ReplyDeleteThank u sir for giving coding of splash screen
ReplyDelete