Quantcast
Channel: VBForums - CodeBank - Visual Basic 6 and earlier
Viewing all articles
Browse latest Browse all 1460

Simple Progress Bar

$
0
0
Here is a simple progress bar using a Label control.

Form contains 1 Command button (Command1), 1 Timer (Timer1),
and 1 label (PBar):
Alignment = 2 - Center
Appearance = 0 - Flat
BackColor = (your choice)
BackStyle = 1 - Opaque
BorderStyle = 1 Fixed single
Caption = {blank)
Height = 255
Left = 0
Width = 15
Code:

Option Explicit

Dim PBarInc As Long

Private Sub Command1_Click()
    PBar.Top = Me.ScaleHeight - PBar.Height 'Position at bottom of form
    PBarInc = Me.ScaleWidth / 100 'Determine increment using form width
    PBar.Caption = "Loading"
    Timer1.Enabled = True 'Start
End Sub

Private Sub Timer1_Timer()
    PBar.Width = PBar.Width + PBarInc
    If PBar.Width >= Me.ScaleWidth Then
        Timer1.Enabled = False
        PBar.Width = 0
    End If
End Sub

A Label control will not overlay nongraphical controls such as CommandButton, Checkbox, or ListBox, but can overlay another Label control or graphic object. The download shows the PBar being used over a Status bar Label.

J.A. Coutts
Attached Files

Viewing all articles
Browse latest Browse all 1460

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>