-
I've seen hundreds of ProgressBar examples but they all deal with 1 file or 1 whatever.
How do I do it for more:
Example: I already have a progress bar working with one file, I now want a second progress bar for all ( a global one), which would be doing total for 5 files if I were copying them.
I can't quite get my head around it......
Anyone ?
-
<?>
'assuming you know how to move the files and can
'change the code accordingly
'with this example I list 269 files in a listbox
'and use the progress bar to measure it's progress
Option Explicit
Private Sub Command1_Click()
'get the count of files in the foler used
Dim sCount As Integer
Dim FSO As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
Set FSO = FSO.GetFolder("C:\wayne vb programs\tips2 pgm\vbcode\")
sCount = FSO.Files.Count
Dim Counter As Integer
ProgressBar1.Visible = True
'Set the Progress's Value to Min.
ProgressBar1.Value = ProgressBar1.Min
'set the max for the progress bar
ProgressBar1.Max = sCount
Dim stFile As String
Dim stDir As String
stDir = "C:\wayne vb programs\tips2 pgm\vbcode\"
stFile = Dir$(stDir & "*.*")
For Counter = 1 To sCount
List1.AddItem stFile
stFile = Dir
ProgressBar1.Value = Counter
Next Counter
End Sub
Private Sub Form_Load()
ProgressBar1.Align = vbAlignTop
ProgressBar1.Visible = False
End Sub
[/code]
-
...assuming all the files are the same size!
to do it by the total number of bytes, all you need to do is add all the lengths together and take a percentage of how many bytes have been copied already. Thats the tricky part, however!