Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS ProgressBar Control, Ver. 6.0

Status
Not open for further replies.

jerseyboy

Technical User
Mar 7, 2002
127
US
I know what it does, but I haven't a clue to go about implementing it.

I have a backup routine that copies the folder (where the database resides) to another location naming it with a NOW() type naming convention.

That all works, but I would like to display a progress bar on how the copying task is going.

Although I have a novice to moderate knowledge of VB (&VBA), I haven't an idea of how to determine the progress of the copy task.

Appreciate the help. JerseyBoy
Remember: self-praise is no recommendation
 
Hi,

Instead of using the progressbar you suggest you could check out the syscmd


This is easy to implement and you do not have to add references.

I do not know how you copy the files so I can not help you on the second question. Maybe you can give some more information about the way you copy the files?

good luck.
 
I have actually written my own progress bar, rather than using the Minrosoft one. Basically, I created a form (frmProgress) that has two boxes on it, plus a label.

Then in the module for the form, I have created a number of properties, that let you set what text the label will display, and set the progress.

Here is the module text, you can probably work out what the form looks like.
Code:
Option Compare Database
Option Explicit

Private m_lngDenominator As Long
Private m_lngNumerator As Long
Private m_boolUseIterative As Boolean

Private Property Let Progress(intPercentProgress As Integer)
    boxProgress.Width = boxBackground.Width * (intPercentProgress / 100)
    Me.Repaint
End Property

Public Property Let Description(strDescription As String)
    lblDescription.Caption = strDescription
End Property

Private Sub Form_Load()
    Progress = 0
    Me.Visible = True
End Sub

Public Property Let UnitsToComplete(lngUnits As Long)
    m_lngDenominator = lngUnits
    m_boolUseIterative = True
End Property

Public Sub Increment()
    If m_boolUseIterative Then
        m_lngNumerator = m_lngNumerator + 1
        Progress = (m_lngNumerator * 100) / (m_lngDenominator)
    Else
        Err.Raise vbObjectError + 20000, "ProgressBar", "You cannot increment the progress as the total work required has not been set"
    End If
End Sub

Note that you can change the Progress property Let to Public if you would rather acces the value directly. I found that in the current app I am writing, it was much simpler (and transparent) coding to not use that syntax.

Now to use the Progress Bar, use the following syntax in your copy code..
Code:
 dim ProgressBar as Form_frmProgress
set ProgressBar = new Form_frmProgress
'set up the total number of operations for 100% complete.
ProgressBar.UnitsToComplete = abcdefg 'your number

'Now after each successful step
ProgressBar.Increment

'The form will automatically close when the procedure ends, if you declare ProgressBar locally.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top