Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

BUG: Application Error When You Use DoEvents in WebBrowser ProgressChange Event


View products that this article applies to.

This article was previously published under Q281118

↑ Back to the top


Symptoms

When you use the DoEvents function in a WebBrowser control ProgressChange event, you may receive the following application error:
The instruction at "address" referenced memory at "address". The memory could not be read.
Click on OK to terminate the application
Click on CANCEL to debug the application

↑ Back to the top


Resolution

There are two ways to work around this problem:
  • Use a Timer to yield to the processor.
  • Delegate the task to an ActiveX EXE component.
If you delegate the task to an ActiveX EXE component, the task can continue completely independent of your application, and the operating system takes care of multitasking and time slicing.

↑ Back to the top


Status

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

↑ Back to the top


More information

Steps to Reproduce Behavior

  1. In Microsoft Visual Basic, create a new standard EXE project. Form1 is created by default.
  2. Under Project, click Components, and then select a reference to Microsoft Internet Controls.
  3. Add the WebBrowser control to your form.
  4. On Form1, add two command button controls (named "Back" and "Forward") and one text box control.
  5. In the code window of Form1, paste the following code:
    Private Sub Command1_Click()
    
        On Error Resume Next
        WebBrowser1.GoBack
    
    End Sub
    
    Private Sub Command2_Click()
    
        On Error Resume Next
        WebBrowser1.GoForward
    
    End Sub
    
    Private Sub Form_Load()
    
        WebBrowser1.Navigate2 "http://www.microsoft.com"
        Command1.Caption = "Go Back"
        Command2.Caption = "Go Forward"
    
    End Sub
    
    Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    
        Text1.Text = WebBrowser1.LocationURL
    
    End Sub
    
    Private Sub WebBrowser1_ProgressChange(ByVal Progress As Long, ByVal ProgressMax As Long)
    
        DoEvents
    
    End Sub
    					
  6. Run the project on a computer with Internet Explorer 5.5.
  7. Browse through a few Web pages to build up the history list.
  8. Click Back and Forward quickly to browse through the history. Eventually, you receive the above-mentioned error.
NOTE: This problem occurs both in Visual Basic Integrated Development Environment (IDE) mode and in the compiled version of the project.

↑ Back to the top


References

For more information about developing Web-based solutions for Microsoft Internet Explorer, visit the following Microsoft Web sites:

↑ Back to the top


Keywords: KB281118, kbwebbrowser, kbnofix, kbbug

↑ Back to the top

Article Info
Article ID : 281118
Revision : 3
Created on : 5/11/2006
Published on : 5/11/2006
Exists online : False
Views : 293