Microsoft KB Archive/281118

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

Article ID: 281118

Article Last Modified on 5/11/2006

-

APPLIES TO


 * Microsoft Internet Explorer 5.5

-



This article was previously published under Q281118



SYMPTOMS
When you use the DoEvents function in a WebBrowser control ProgressChange event, you may receive the following application error:

The instruction at &quot;address&quot; referenced memory at &quot;address&quot;. The memory could not be read.

Click on OK to terminate the application

Click on CANCEL to debug the application



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.



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



Steps to Reproduce Behavior
 In Microsoft Visual Basic, create a new standard EXE project. Form1 is created by default. Under Project, click Components, and then select a reference to Microsoft Internet Controls. Add the WebBrowser control to your form. On Form1, add two command button controls (named &quot;Back&quot; and &quot;Forward&quot;) and one text box control.  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 &quot;http://www.microsoft.com&quot; Command1.Caption = &quot;Go Back&quot; Command2.Caption = &quot;Go Forward&quot;

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  Run the project on a computer with Internet Explorer 5.5.</li> Browse through a few Web pages to build up the history list.</li> Click Back and Forward quickly to browse through the history. Eventually, you receive the above-mentioned error.</li></ol>

NOTE: This problem occurs both in Visual Basic Integrated Development Environment (IDE) mode and in the compiled version of the project.

<div class="references_section">