Link to home
Start Free TrialLog in
Avatar of StewSupport
StewSupport

asked on

progress bar in vb.net

how can i make the progress bar work ? let's say i'm reading rows in a file or inserting records into database or retrieving it from database, i want to be able to move the bar up when the number of record too. say 100 records right i want progress bar to move up a bit, 200 move up 300 move to the middle then at the end just complete or better if you can make the progress bar says 1% Done 50% done and so on. thank you
vs 2005 framework 2.0
Avatar of Jeff Certain
Jeff Certain
Flag of United States of America image

Just set the progress bar progress to the number matching the percentage complete.

        Dim pb As New ProgressBar
        Dim recordCount As Integer = 426
        Dim recordProgress As Integer = 20
        pb.Minimum = 0
        pb.Maximum = recordCount
        pb.Value = recordProgress

Open in new window

Avatar of StewSupport
StewSupport

ASKER

the number of record is dynamic i guess i can return the count form database but the rcord in progress how would you get that?
Since you're specifically asking about database reads, there's a couple additional considerations:

1. Using DataAdapter, you have no way to get the progress within a table or dataset fill.
2. Using DataReader, you have no way of knowing how many records are coming back.

File and database writes are easy -- you know how many records are being sent.

Reads are trickier -- we've generally guesstimated the time, and set the progress bar to update on a timer.
I assume you're using DataAdapter.Fill(DatTable) then?
mostly reader but if you can do both adapter and reader. that is good too.
ASKER CERTIFIED SOLUTION
Avatar of Jeff Certain
Jeff Certain
Flag of United States of America 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
when it gets to 101 it says Value of '101' is not valid for 'Value'. 'Value' should be between 'minimum' and 'maximum'.
Parameter name: Value
 For i As Integer = 0 To 1000 Step 1
            ProgressBar1.Value = i
        Next

? why is taht
Just means that you forgot to set the max value for the progress bar -- default is 0 as min and 100 as max.
ok when i tried to do while readers.read

that doesn't work it goes up to half and just stay there. and it moves to the end of the bar really fast like half second. how do i make it go slower and correspond to the number of record. basically if halfway done then it should only get to halfway on the progressbar and only reach the end of the bar when its done. i tried ur chaosian that was what i got.
Can you post your code for the reader please?
good