Resolved Problem programming ProgressBar into my web browser

sega dude

New member
Joined
Apr 14, 2011
Messages
3
Location
New York, United States
Programming Experience
1-3
I am having a problem programming a ProgressBar into my web browser. I don't get any build errors but once the web page starts to load I get thrown an exception. http://img200.imageshack.us/img200/8923/bwexception.png This is the code im using.
VB.NET:
Private Sub WebBrowser1_ProgressChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs) Handles WebBrowser1.ProgressChanged
        ToolStripProgressBar1.Value = e.CurrentProgress
    End Sub

How do I get this to work? Why is this happening?
 
Last edited:
The issue is that the CurrentProgress is greater than the ProgressBar's maximum value. I am not sure if there is a better way or not, but this works:

Change this:

VB.NET:
Private Sub WebBrowser1_ProgressChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs) Handles WebBrowser1.ProgressChanged
    ToolStripProgressBar1.Value = e.CurrentProgress
End Sub

To this:

VB.NET:
Private Sub WebBrowser1_ProgressChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs) Handles WebBrowser1.ProgressChanged
    ToolStripProgressBar1.Maximum = e.MaximumProgress
    ToolStripProgressBar1.Value = e.CurrentProgress
End Sub

Hope this helps
-Josh
 
Sorry, try this:

VB.NET:
Private Sub WebBrowser1_ProgressChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs) Handles WebBrowser1.ProgressChanged
    If e.MaximunProgress = -1 Or e.CurrentProgress = -1 Then Exit Sub
    ToolStripProgressBar1.Maximum = e.MaximumProgress
    ToolStripProgressBar1.Value = e.CurrentProgress
End Sub

-Josh
 
Glad too help!
 

Latest posts

Back
Top