English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I have this code so far that makes a working timer:

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Start()
Timer1.Enabled = True

End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
MessageBox.Show("Times Up")
Timer1.Enabled = False

End Sub

Private Sub ProgressBar1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProgressBar1.Click

End Sub
End Class

I want to allow the progress bar to track the progress of th timer. The timer will be set for 1 hour and I want the progress bar to performstep every 10 seconds and perform a total of 360 steps.

2007-06-04 00:00:10 · 2 answers · asked by Game-Guy Pro 5 in Computers & Internet Programming & Design

2 answers

A progress bar can be easily setup to display a percentage of completion. Since you know the duration of the timer and the timers current value you should be able to easily compute a percentage and update the progress bar value during a timer tick event.

If you donot want to compute percentages then you will have to modify the min and max vaules and provide a totalizer variable. This variable would be updated using method one below.

Looking at your code you have one time which is timing the duration. You will need to do one of two things to have your prograss bar update....

Easiest...
1.) Add a second timer set to fire every 10 seconds. This timer will be used to compute the percentage and update the display.

Hardest..
2.Rewrite your code using only a single timer which is used to not only update the displays as in #1 but also reads the system clock and totalizes the timespan between the current and previous system clock values. Uning the system clock is more accurate than the Timer control if accuracy is going to be an issue.

2007-06-04 01:49:43 · answer #1 · answered by MarkG 7 · 0 0

Its better not to use progress bar since the code will increase..

2007-06-04 00:08:10 · answer #2 · answered by Mohammed 1 · 0 2

fedest.com, questions and answers