Adding Progress bar to a browser

jamesellis_2001
jamesellis_2001 used Ask the Experts™
on
Hi

Im in the process of making an internet browser.  And i would like to know how i could add a progress bar to show the percentage completion of a webpage loading.  Could you help me please??

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
The webbrowser has an event called ProgressChange that gives you the current Progress, and the maximum progress.  Add a progress bar with a min of 0 and a max of 100 and add something like this:


Private Sub WebBrowser_ProgressChange(ByVal Progress As Long, ByVal ProgressMax As Long)

    If Progress = -1 Then
        ProgressBar.Value = 100
    Else
        ProgressBar.Value = (Progress/ProgressMax) * 100
    End If
End Sub

Commented:
Go to Project > Components and scroll down and find Microsoft Windows Common Controls 6.0 (SP3)

Select the checkbox and you will now see a "ProgressBar" icon on the toolbox menu.  Just paint this onto your window/form and you're ready to roll!

It's fairly easy to use, you set the min & max value and then just increment the value as you step through your loop(s).

Author

Commented:
thanks AzraSound, although i paste the code into my project.  And changed the names of the objects.  Although when i run the program it comes up with 'overflow'?!?!
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
I altered the code slightly although When the webpage load is complete A caption comes up saying "overflow"

Author

Commented:
I altered the code slightly although When the webpage load is complete A caption comes up saying "overflow"

Commented:
You're probably getting an overflow because the max value of the ProgressBar might be 100.  Try doing some division so your max never exceeds 100.

Commented:
And also, you need to define the .max and .min property to whatever the max and min value is going to be.  By default, they are zero or one.
Here, found this from an old app of mine:

Private Sub wb1_ProgressChange(ByVal Progress As Long, ByVal ProgressMax As Long)
    On Error Resume Next
    If Progress = -1 Then Exit Sub
    If Int(((Progress * 100) / ProgressMax)) < 100 Then
        proBar1.Value = Int(((Progress * 100) / ProgressMax))
    End If
End Sub

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial