Progress Bar control in Visual Basic.net

The Windows progress bar control represents the visual feedback to the users about the current status of any task. And it shows the bar that fills from left to right representing the operation progress. In this tutorial we will focus on how to put the prograess bar control and its functionality using visual basic. And here’s the final output of our project. To start building this program, open visual basic and create a new project and name it according to your will. Then add two buttons, a progress bar, a Timer and a label.
Object			Property		Settings
Button1			Name			btnstart
			Text			Start
Button2			Name			btnstop
			Text			Stop
Progressbar1		Name			Default
Label1			Name			lblprocess
			Text			ProgressBar Value: Timer1			Name			Default
Next let’s add functionality to our application. Double click the “timer1” control and add the following code:
  1. 'it test if the progressbar current value is greater than or equal to the set maximum value
  2. If ProgressBar1.Value >= ProgressBar1.Maximum Then
  3. 'if it is true the progress bar value will be reset into 0
  4. ProgressBar1.Value = 0
  5. lblprocess.Text = ProgressBar1.Value
  6. Else
  7. 'else the progressbar value will incremented by 20 until such time it will reach the maximum value
  8. ProgressBar1.Value += 20
  9. End If
  10. lblprocess.Text = ProgressBar1.Value
  11. lblprocess.Text = "ProgressBar Value: " & lblprocess.Text
Next, add this code to our “Start” button.
  1. 'it start the timer
  2. Timer1.Start()
  3. 'check if the button text is set into Continue the it will set into Start
  4. If btnstart.Text = "Continue" Then
  5. btnstart.Text = "Start"
  6. End If
Then for “Stop” button.
  1. 'it stop the timer
  2. Timer1.Stop()
  3. 'set the text of btstart into Continue
  4. btnstart.Text = "Continue"
Now let's start testing our program by pressing "F5".

Add new comment