How to Make a Repeating Progress Bar in VB

Written by jaime avelar
  • Share
  • Tweet
  • Share
  • Email

Adding a repeating progress bar in Microsoft Visual Basic (VB) can make your application more user-friendly; it communicates to the user that the application is working in the background. A progress bar control visually indicates the progress of a lengthy operation by showing a continuous bar that fills in from left to right. You can continuously show the same progress bar repeating itself by using a "While...Loop" and changing the value of the progress bar.

Skill level:

Other People Are Reading

Things you need

  • Microsoft Visual Studio

Show MoreHide


  1. 1

    Launch Microsoft Visual Studio, click "New Project" from the left pane of your computer screen, and expand "Visual Basic" below "Installed Templates." Click "Windows" and double-click "Windows Forms Application" from the centre of the dialogue window to create a new project.

  2. 2

    Double-click "ProgressBar" from the "Toolbox" pane to add a new progress bar control. Double-click "Button" to add a new button to the form. Add a second button.

  3. 3

    Double-click "Button1" to create a new button click event. Add the following code to create a loop to repeat the progress bar until the user clicks the second button:

    Dim xCntr As Integer

        xCntr = 1
        userWantsToStop = False
        Me.ProgressBar1.Minimum = 0
        Me.ProgressBar1.Maximum = 1000
        Do While (userWantsToStop = False)
            Me.ProgressBar1.Value = xCntr
            If (xCntr = 1000) Then
                xCntr = 1
            End If
            xCntr = xCntr + 1
  4. 4

    Switch back to Form Design view and double-click "Button2" to create a click event for this button. Add the following code to reset the progress bar and stop the while loop in the previous step:

    userWantsToStop = True

    Me.ProgressBar1.Value = 0

  5. 5

    Press "F5" to run the program and click "Button1" to start repeating the progress bar. Click "Button2" to stop it.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.