Link to home
Start Free TrialLog in
Avatar of adammyers
adammyers

asked on

Progress Bar In VB6

I thought I could do this, but dont know the code or the property I need to look at.

Is there any way to turn the standard Progress Bar into a solid bar ?

Does this increase the resolution of the bar or does it just join the boxes that are in the standard bar ?

Kind Regards
Mike Marriott
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

There is no property to make the standard Progress Bar solid.

It is very easy to write your own Progress Bar though using a PictureBox.  The example below allows you to also have your own custom text inside the progress bar.

Create a new project and add a long thin PictureBox about the size as a Progess Bar and one CommandButton:

Option Explicit

Private Sub Form_Load()
    Picture1.AutoRedraw = True
    Picture1.BackColor = vbWhite
    Picture1.ForeColor = vbBlue
    Picture1.ScaleWidth = 100
    Picture1.DrawMode = vbNotXorPen
End Sub

Private Sub Command1_Click()
    Dim i As Integer
    Dim f As Integer
    Dim m As String
     
    f = 10000
    For i = 1 To f
        m = "Processing File " & i & " of " & f
        updateProgressBar m, i, f
        DoEvents
    Next i
End Sub

Private Sub updateProgressBar(ByVal msg As String, ByVal value As Integer, ByVal max As Integer)
    Dim p As Integer
   
    Picture1.Cls
    Picture1.CurrentX = (Picture1.ScaleWidth - Picture1.TextWidth(msg)) \ 2
    Picture1.CurrentY = (Picture1.ScaleHeight - Picture1.TextHeight(msg)) \ 2
    Picture1.Print msg
    p = Int(value / max * 100)
    Picture1.Line (0, 0)-(p, Picture1.ScaleHeight), Picture1.ForeColor, BF
End Sub

Actually there is a property to make the standard scrollbar solid. Its the "Scolling" property, it has two settings (ccScrollingStandard and ccScrollingSmooth).

ccScrollingStandard uses the individual blocks.
ccScrollingSmooth uses a solid contiuous line.

Hope this helps.
I stand corrected.

Thank you carl_tawn.

Idle_Mind
Avatar of adammyers
adammyers

ASKER

Running VB6 SP5, I have the following properties for the progress bar;
(About)
(Custom)
(Name)
Align
Appearance
BorderStyle
DragIcon
DragMode
Enabled
Height
Index
Left
Max
Min
MouseIcon
MousePointer
Negotiate
OLEDropMode
TabIndex
Tag
ToolTipText
Top
Visible
WhatsThisHelpID
Width

I can find where I need to set the property,

If I use

ProgressBar1.Scroll = ccScrollingSmooth

I just get an error when I run the program.

Regards
Mike
ASKER CERTIFIED SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Bingo,

I Was using 5.0 !

Thanks !