Click here to Skip to main content
Click here to Skip to main content
Technical Blog

Tagged as

Visual Basic Progress Bar control

, 17 Mar 2014 CPOL
Rate this:
Please Sign up or sign in to vote.
Visual Basic Progress Bar control provides the coolest way to show the progress of any background activity. It is good idea to show the progress to the end user when …The post Visual Basic Progress Bar control appeared first on Bubble Blog.

Visual Basic Progress Bar control provides the coolest way to show the progress of any background activity. It is good idea to show the progress to the end user when an application is performing complex or time consuming background tasks. Follow steps below to begin with:

  1. Drag and drop a progress bar control ProgressBar1 and button Button1 on the Form Design
  1. Dock the ProgressBar1 on the bottom sideVisual Basic Progress Bar
  1.  Go to ProgressBar1 properties and modify Step property value to 15Visual Basic Progress Bar
  1.  Open code for Button1_Click event handling sub and paste following code in it
ProgressBar1.PerformStep()
  1. Run the application using F5. Now whenever you press the Button1, the progress bar value is incremented to next step. We had updated the Step property to 15, so every step increases the progress bar by value of 15. Note that PerformStep() method does nothing when ProgressBar1 value is reached to the Maximum. The default value for Maximum is 100

Visual Basic Progress Bar

Properties for Visual Basic Progress Bar Control

Style

Style provides three display options for visual appearance

Blocks: The progress bar is shown in block increments. This option is not usable in modern windows

Continuous: The progress bar is shown as a continuous bar. This is the most common value of Style property

Marquee: Sometimes we are not sure about the exact progress of a background task. In such cases we use the Marquee style which shows the progress bar as always moving

Step

This property provides the value of the incremental step when PerfromStep() method is called.

MarqueeAnimationSpeed

You can control the speed of moving progress bar animation. Default value is 100. The smaller the value, the faster will be the animation speed

 

Modifying value of Visual Basic Progress Bar in Code

Modify the Windows Application code as below:

Public Class Form1
    Dim increment As Integer = 0

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        increment = increment + 10
        If increment > ProgressBar1.Maximum Then
            increment = ProgressBar1.Maximum
        End If
        ProgressBar1.Value = increment

    End Sub

End Class

Tips

  • This code increases the progress bar value by 10 every time Button1 is pressed.
  • Whenever we are modifying the code of progress bar value, we must check whether the assigned value is less than the Maximum. A runtime error or exception will be returned if we assign a value greater than Maximum. The code is self-explanatory for this purpose
  • Please note that we have not used PerformStep() method in this code
  • We don’t have to perform value checks while using PerformStep(). It makes the coding much easier. Just define the value of Step property for progress bar and PerformStep() will increase the value by that step. Simple is that!

 

The post Visual Basic Progress Bar control appeared first on Bubble Blog.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Sharjeel_Ahmad
Engineer http://bubbleblog.net/
Pakistan Pakistan
A Telecom Engineer, Visual Basic enthusiast and Android news follower. He is contributing to an online blog as content writer and administrator
You can visit him here: http://bubbleblog.net/
Follow on   Twitter   Google+   LinkedIn

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141220.1 | Last Updated 17 Mar 2014
Article Copyright 2014 by Sharjeel_Ahmad
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid