A visual basic ProgressBar
control shows the progress of a task. it shows how much time a user has to wait
to accomplish the task. ProgressBar are commonly used for downloading, file
transfer. progress bar consist the rectangles of green color which shows the
progress of the task.
ProgressBar control are of two
types:
- Determinate ProgressBar control
- indeterminate ProgressBar control
.
Determinate ProgressBar shows the sequential
representation of a work and the scope of the work is known to you.
Indeterminate ProgressBar
control is represent time based works and the scope of the works is not known to
you.
The below Example Shows the ProgressBar with button and MouseWheel Event
Private Sub Form1_Load(ByVal
sender As System.Object,
ByVal e As
System.EventArgs)HandlesMyBase.Load
ProgressBar1.Minimum = 0
ProgressBar1.Maximum = 100
ProgressBar1.Value = 0
End Sub
Then we take four button code for button is
shown below
Private Sub Button2_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs)
Handles Button2.Click
If
ProgressBar1.Value > 0 Then
ProgressBar1.Value -= 5
End If
End Sub
-
Button 3
Private Sub Button3_Click(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles Button3.Click
ProgressBar1.Value = 100
End Sub
-
Button 4
Private Sub Button4_Click(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles Button4.Click
ProgressBar1.Value = 0
End Sub
Now we write code for MouseWheel event
Private Sub Form1_MouseWheel(ByVal sender As Object,ByVal e As System.Windows.Forms.MouseEventArgs)Handles
Me.MouseWheel
If e.Delta > -1 Then
If ProgressBar1.Value < 100 Then
ProgressBar1.Value += 5
End If
Else
If ProgressBar1.Value > 0Then
ProgressBar1.Value -= 5
End If
End If
End Sub
Output:




