VB.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 307,167 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,551 people online right now. Registration is fast and FREE... Join Now!




Need Progress bar progress help!

 

Need Progress bar progress help!, Is theren't a althrogram for caclulating total of downloaded files

EvolutionMedia

16 Sep, 2008 - 09:09 AM
Post #1

D.I.C Head
**

Joined: 11 Aug, 2008
Posts: 119



Thanked: 3 times
My Contributions
Hey

In my program it gathers files from the internet and in the progress bar I would like to calculate the progress bar.
So, I have a timer ont he form set to 50 interval and disenabled. When the search function is doing it's thing then it turns on enabled.

So say if there is 17 files and it downloaded like 5 files so far. I thought it would be like 17 / 5 * 100. Also, I adjusted the progress bar step.

Here's the code that I adjusted the progress bar step.
CODE

' Update the status progressbar step to 100 divide by amount of images in page.

        main_form.StatusProgressBar1.Step = Int(100 / main_form.WebBrowser1.Document.DomDocument.images.length - 1)


Inside the timer1_tick I have this:

CODE

' See if progress bar reached 100 percent

        If StatusProgressBar1.Value = 100 Then
            StatusProgressBar1.Value = 0
            Percent_countlable.Text = ""
            ToolStripStatusLabel1.Text = "Done"
            Cursor = Cursors.Default
            New_SearchCMD.Enabled = True
            Timer1.Stop()

        Else

            StatusProgressBar1.Value = Int((StatusProgressBar1.Value) + 1)

            ToolStripStatusLabel1.Text = "Gathering Data..."

        End If


Is there a way? Thanks!

Sincerely,

Evolution

User is offlineProfile CardPM
+Quote Post


Jayman

RE: Need Progress Bar Progress Help!

16 Sep, 2008 - 09:53 AM
Post #2

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 8,570



Thanked: 237 times
Dream Kudos: 500
Expert In: Everything

My Contributions
You equation is close, however to determine the percentage downloaded you need to calculate it this way. You just had the division backwards.

5 / 17 * 100 = 29.4%

So tie that equation to the Value property of the ProgressBar and you will get a more accurate percentage. You will need a counter to keep track of how many images have been downloaded to reuse in the equation each time it updates.
User is offlineProfile CardPM
+Quote Post

magicmonkey

RE: Need Progress Bar Progress Help!

16 Sep, 2008 - 10:25 AM
Post #3

D.I.C Regular
***

Joined: 12 Sep, 2008
Posts: 484



Thanked: 97 times
My Contributions
Figure out the percentage as above and just apply that logic to the progress bar with a range of 0 to 100. And never use the progress bar properties to determine if you have reached the end of your logic.

Warning this code is free hand... might have a few typos.
CODE


Private Sub DownloadImages()
    UpdateProgress (0, "Downloading...")
    For dlIndex = 0 to ImagesToDownload.Count - 1
        UpdateProgress( (dlindex + 1) / ImagesToDownload.Count * 100, "Downloading " & dlIndex + 1 & " of " & ImagesToDownload.Count)
        DownloadImage(ImagesToDownload(dlIndex))
    Next
    UpdateProgress (100, "Download Complete")
End Sub

...

Private Sub UpdateProgress(Percentage as Integer, Message as String)
    ProgressBar.Value = Percentage
    LabelStatus.Text = Message
    Application.DoEvents() 'Let Form Update
End Sub

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 06:22PM

Live VB.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month