Progress Bar is used to give visualization about the status of the current process and computer operation, such as a downloading , transferring of files, installation and more. Your application will look more professional if you are implementing a complex data processing using the Progress Bar.
This time, we will create an example of a Progress Bar using Visual Basic. First, open visual basic and create a new project then, save it as “ProgressBar”. Then from the toolbox add a progressbar,label, button and a timer.
Next, we’re going to add functionality to our application. First, you need to set the progress bar's minimum value to 0 and the maximum value to 100. And double click the timer1, and add the following code:
'test if the value of progress bar is greater than or equal to 100
If ProgressBar1.Value >= 100 Then
'set the value to minimum value which is equal to zero
ProgressBar1.Value = 0
Else
'increment the value of progress bar by 1
ProgressBar1.Value = ProgressBar1.Value + 1
'display the current percent of the progress.
Label1.Text = ProgressBar1.Value & "% Completing..."
End If
To activate the timer, double click the button. And add the following code:
Then press “F5” to run your application.
Here’s the example output after completing the course.
