Welcome to ADO.NET Access 2003—your ultimate hub for VB.NET and ADO.NET programming excellence. Discover in-depth tutorials, practical code samples, and expert troubleshooting guides covering a broad range of topics—from building robust WinForms applications and seamless MS Access integration to working with SQL Server, MySQL, and advanced tools like WebView2 and Crystal Reports. Whether you're a beginner or a seasoned developer, our step-by-step articles are designed to empower you to optimize.

Looking for MS Access Developer❓❓

Application developer

Post Page Advertisement [Top]

VB Developers
Progress Bar Control

VB 2010 Progress bar - Visual Basic Online Course
VB 2010 Progress bar - Visual Basic Online Course

🧠Using the ProgressBar control Example :

🗣️Logic

We will generate 4 Message Boxes by clicking the Button1 Control and every time a message box shows up, a ProgressBar step will be taken.
Github Gist File


      'Visual Basic Online Course
'evry1.net/VBNet
'Adonetaccess2003.blogspot.com
'ProgressBar example
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click

Dim I As Integer
With ProgressBar1
.Value = 0
.Maximum = 3 '(4 times : 0,1,2,3)
.Step = 1 '(1 step, every messagebox)
For I = 0 To 3 
'(Must be between the Minimum(0) and Maximum(3) values)
MsgBox ("hello!")
.PerformStep() '(do it)
Next I
.Value = 0 '(Reset the ProgressBar)
End With
End Sub
🐭Progress Bar Class : In .Net Framework 4.0

A ProgressBar control consists of a window that is filled, by default from left to right, as an operation progresses. The control has a range and a current position.
ProgressBar overrides the metadata of the Maximum property and sets its default to 100. 
ProgressBar overrides the metadata of the Focusable property and sets its default to false. For more information, see Dependency Properties Overview.

🖼️Customizing the ProgressBar Control

To apply the same property settings to multiple Progress Bar controls, use the Style property. You can modify the default ControlTemplate to give the control a unique appearance. For more information about creating a ControlTemplate, see Customizing the Appearance of an Existing Control by Creating a ControlTemplate. To see the parts and states that are specific to the ProgressBar, see ProgressBar Styles and Templates.
Dependency properties for this control might be set by the control’s default style. If a property is set by a default style, the property might change from its default value when the control appears in the application. The default style is determined by which desktop theme is used when the application is running. For more information, see Default WPF Themes.

🐍Note

Setting a visual property will only have an effect if that property is both present in ProgressBar control's default template and is set by using a Template Binding. You can find a list of visual properties in the "Changing the Visual Structure of a Control" section in Customizing the Appearance of an Existing Control by Creating a Control Template. 

🥈How to call a Progress Bar from a Module in VB 2010

In addition to our example about Progress Bar, what if we wanted to code the progress bar to call it from another level [Module Level] !

  1. Create Visual Basic 2010 Windows Form Application
  2. Place a Progressbar (Progressbar1) control on the Form (Form1
  3. Add new Module (Module1)
👩🏿‍🎤Code
Github Gist File
'Visual Basic Online Course
'VB 2010 Progress Bar
'Place this code in the Module section
Module Module1
   Public ProBar1 As ProgressBar = New ProgressBar
End Module

'Place this code in your form [Form1]
Public Class Form1

   Private Sub Form1_Click(sender As Object, _
   e As System.EventArgs) Handles Me.Click
      ' Display the ProgressBar control.
      ProBar1.Visible = True
      ' Set Minimum to 1 to represent the first file being copied.
      ProBar1.Minimum = 1
      ' Set Maximum to the total number of files to copy.
      ProBar1.Maximum = 100
      ' Set the initial value of the ProgressBar.
      ProBar1.Value = 1
      ' Set the Step property to a value of 1 to represent each file being copied.
      ProBar1.Step = 1

      ' Loop through all files to copy.
      Dim x As Integer
      For x = 1 To 100 - 1
         ' Copy the file and increment the ProgressBar if successful.
         If x <= 100 Then
            ' Perform the increment on the ProgressBar.
            ProBar1.PerformStep()
         End If
      Next x
   End Sub

   Private Sub Form1_Load(sender As System.Object, _
   e As System.EventArgs) Handles MyBase.Load
      ProgressBar1 = ProBar1
   End Sub
           End Class

Now, run your application and click on any part of the Form1, you will notice that the ProgressBar is working.


👺Create your Custom Progressbar with text showing (%) progress:

  • Create new VB .NET project [WinForm].
  • Add Class, name it [ProgressBarWithText.vb]
  • Copy and Paste this code below :
  • How to use this control [ProgressBarWithText.vb] in your project.
  • Create new form [Form1.vb]
  • Rebuild your VB .NET project.
  • While displaying the Form1 Design, Open your Toolbox and place your new Control on Form1

vb net Custom Progress Bar With Text
Custom Progress Bar With Text

  • Apply the above example using the new Custom Progress Bar.
  • Run your WinForms Project.

VB .NET WinForms Progressbar Helper
Custom Progress Bar With Text - Example Project

 Here are some online Visual Basic lessons and courses:

Bottom Ad [Post Page]