Practical
Learning: Creating the Application
|
|
- Start a new Windows Application named ProgressClock1
- Design the form as follows:
 |
Control |
Text |
Name |
Other Properties |
Label |
 |
Time |
|
Anchor: Right |
Label |
 |
Hours: |
|
|
ProgressBar |
 |
00 |
pgrHours |
Anchor: Left, Right
Style: Continuous
Maximum:
23
Minimum: 1 |
Label |
 |
|
lblHours |
|
Label |
 |
Minutes: |
|
|
ProgressBar |
 |
|
pgrMinutes |
Anchor: Left, Right
Style: Continuous
Maximum: 59
Minimum: 1 |
Label |
 |
00 |
lblMinutes |
Anchor: Right |
Label |
 |
Seconds: |
|
|
ProgressBar |
 |
|
pgrSeconds |
Anchor: Left, Right
Style: Continuous
Maximum: 59
Minimum: 1 |
Label |
 |
00 |
lblSeconds |
Anchor: Right |
Button |
 |
Close |
btnClose |
Anchor: Right |
Timer |
 |
|
|
Enabled: True
Interval: 20 |
|
- Double-click the timer control to generate its Tick event and implement
it as follows:
Private Sub timer1Tick(ByVal sender As System.Object,
ByVal e As System.EventArgs)
Handles timer1.Tick
' Get the current time
Dim curTime As DateTime = DateTime.Now
' Retrieve the hour value of the current time
Dim H As Integer = curTime.Hour
' Retrieve the minute value of the current time
Dim M As Integer = curTime.Minute
' Retrieve the second value of the current time
Dim S As Integer = curTime.Second
' Draw the progress boxes based on the values of the time
pgrHours.Value = H
pgrMinutes.Value = M
pgrSeconds.Value = S
' Display the values in the corresponding labels
lblHours.Text = CStr(H)
lblMinutes.Text = CStr(M)
lblSeconds.Text = CStr(S)
End Sub
|
- In the Class Name combo box, select btnClose
- In the Method Name combo box, select Click and implement the event as
follows:
Private Sub btnCloseClick(ByVal sender As Object,
ByVal e As System.EventArgs)
Handles btnClose.Click
End
End Sub
|
- Execute the application to test it then close the form:

- Close the form and return to your programming environment
|
|