Progress Bar

Progress bars are a very handy control within the Visual Basic environment.

They can give you a visual indicator of how 'far' through a recordset or dataset your application has reached. When searching through a large number of records it is a good way to let the user know that things are 'still happening' and that the system has not hung.

Here we will give a simple example in VB6

  • Open VB and create a new standard project
  • In the Project menu option, choose 'Components' and scroll down the list. You should come to Microsoft Windows Common Controls 6.0 (Depending on which service pack you have installed)
  • Check it and a tick will appear
  • Click OK and more controls will have appeared in the toolbox
  • VB6 Components Menu - Progress Bar VBNow you can drag a progress bar control onto the form. Place it and a command button on the form. We always rename our controls to something meaningul (EG: cmdSave) but for the purposes of this example we won't bother renaming any controls.

    This vb sample program using a progress bar is use for loading / splash screen on your small application.
    download the full source code below for free then try it on your own. enjoy!


    SCREENSHOT


    Private Sub Form_Load()
    Timer1.Enabled = True
    Timer1_Timer
    End Sub

    Private Sub Timer1_Timer()
    ProgressBar1.Value = ProgressBar1.Value + 10
        If ProgressBar1.Value = 80 Then
          ProgressBar1.Value = ProgressBar1 + 20

            If ProgressBar1.Value >= ProgressBar1.Max Then
                Timer1.Enabled = False
            End If
          'In this are you may call the form to be loaded next!
          MsgBox "Loading Complete!", vbInformation, "Info"
          Unload Me
       End If
    End Sub