FIX: Multiple CreateObject May Cause GP Fault in VBOA300.DLL

ID: Q113438


The information in this article applies to:
  • Microsoft Visual Basic programming system for Windows, version 3.0


SYMPTOMS

A general protection (GP) fault may result when working with OLE objects in Visual Basic if you repeatedly create new OLE objects.


CAUSE

When OLE objects are created with Visual Basic and that OLE object is subsequently set to Nothing, a hidden instance of the OLE application is spawned and then orphaned. This uses up system resources and eventually either the machine will hang (stop responding to input) or a GP fault will occur in VBOA300.DLL at 0001:0D03.


WORKAROUND

When you create OLE objects. Be sure to close or quit the OLE object before setting the variable to Nothing. Please see the example at the end of this article.


STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This problem has been corrected in Visual Basic version 4.0.


MORE INFORMATION

Steps to Reproduce Problem

  1. Start a new project in Visual Basic. Form1 is created by default.


  2. Add a command button (Command1) to the form.


  3. Add the following code to the Command1_Click event:
    
       Sub Command1_Click ()
          Dim X As object
          Dim R As object
          Dim Iterations As Integer
    
          While True
             Iterations = Iterations + 1
             Debug.Print Iterations
             Set X = CreateObject("Excel.Sheet.5")
    
             ' Enter the following two lines as one, single line:
             Set R = X.Parent.Sheets(1).Range(X.Parent.Sheets(1).Cells(2, 2),
                X.Parent.Sheets(1).Cells(52, 2))
    
             Set R = Nothing
             Set X = Nothing
          Wend
       End Sub 


  4. Run the program.


When this code is run, the program will eventually produce a GP fault. Closing the WorkBook will not circumvent this problem. You must quit the application to avoid the GP fault.

Example Workaround

The following code will not produce a GP fault:

   Sub Command1_Click ()
      Dim X As object
      Dim R As object
      Dim Iterations As Integer

      While True
         Iterations = Iterations + 1
         Debug.Print Iterations
         Set X = CreateObject("Excel.Sheet.5")

         ' Enter the following two lines as one, single line:
         Set R = X.Parent.Sheets(1).Range(X.Parent.Sheets(1).Cells(2, 2),
            X.Parent.Sheets(1).Cells(52, 2))

         ' The next line quits the application for an Excel object
         X.Application.Quit
         Set R = Nothing
         Set X = Nothing
      Wend
   End Sub 

Additional query words: buglist3.00 GPF EXCEL 5.00 WINWORD 6.00 VBASIC 3.00 fixlist4.00

Keywords :
Version : 3.00
Platform : WINDOWS
Issue type :


Last Reviewed: August 31, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.