|
-
May 19th, 2003, 05:13 PM
#1
Thread Starter
Lively Member
How do you use a progress bar for...
How do you use a progress bar for functions that take a while to do there thing, i.e. one that goes throught multiple recordsets, extracting data, etc, etc?
I understand how to use a ProgessBar in Loops but not generally in something like the above.
-
May 19th, 2003, 05:20 PM
#2
Addicted Member
Hope this works. Put a CommandButton, CommonDialog, Label and ProgressBar into a Form
VB Code:
Private Sub Command1_Click()
Dim Source As String
Dim Dest As String
Dim Data As String
Dim TransferRate As Integer
CommonDialog1.CancelError = True
CommonDialog1.Filter = "All Files|*.*" CommonDialog1.ShowOpen
If Err <> 32755 Then
Source = CommonDialog1.filename
Dest = Source & " - Copy 2"
Open Source For Binary As #1
Open Dest For Binary As #2
ProgressBar1.Max = FileLen(Source)
TransferRate = 1024
Do Until LOF(1) = Loc(1) Or EOF(1)
Data = ""
If LOF(1) - Loc(1) < ChunkSize Then
Data = String(LOF(1) - Loc(1), 0)
Else
Data = String(ChunkSize, 0)
End If Get #1, , Data
Put #2, , Data
Label1.Caption = Loc(1) & " bytes out of " & LOF(1) & " transfered"
If ProgressBar1.Value + TransferRate > FileLen(Source) Then Exit Do
ProgressBar1.Value = ProgressBar1.Value + TransferRate
Loop
End If
End Sub
[vbcode]
If SymptomsPersist Then Goto VBForum
[/vbcode]
This is our world now...the world of the electron and the switch, the beauty of the baud.We make use of a service already existing without paying for what could be dirt cheep if it wasn't run by profiteering gluttons, and you call us criminals. We explore...and you call us criminals. We exist without skin color, without nationality, without religious bias...and you call us criminals. You build atomic bombs, wage wars, murder, cheat, and lie to us and try to make us believe it is for our own good, yet we're the criminals. Yes, I am a criminal. My crime is that of curiosity. My crime is that of judging people by what they say and think, not what they look like. My crime is that of outsmarting you, something that you will never forgive me for. I am a hacker and this is my manifesto.You may stop this individual, but you can't stop us all...after all, we're all alike."
+++The Mentor+++
-
May 19th, 2003, 05:25 PM
#3
Fanatic Member
you can track the progress of an operation only if you know before you get started how many steps it involves (that would be the .Max property of your progress bar) and only if you gain control into your application when each step is done (e.g. the long operation would generate events or something). other than that, you may be able to estimate how long the operation is going to take, and have a timer to modify the .Value of your progress bar every second or so... and you will probably get the micosoft's progress bar effect, when the fill factor either jumps from 35% to 100%, or gets stuck to 99% completed for 50% of the entire time...
there are 2 reasons why i leave my work unfinished:
(1) i'm getting old.
-
May 19th, 2003, 05:27 PM
#4
Thread Starter
Lively Member
Thanks guys.
You've got me thinking along the right track now radum - I'll give that a go and let you know how I get on in this forum thread.
Cheers.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|