The information in this article applies to:
- Standard, Professional, and Enterprise Editions of Microsoft Visual
Basic for Windows, 32-bit only, version 4.0
SYMPTOMS
An application error occurs when you close a Visual Basic program through
the control box if the Visual Basic program executes a command after an
object created from a class module is set to nothing. This problem occurs
only in the 32-bit edition of Visual Basic 4.0.
WORKAROUND
The workaround to this issue is execute all the code in the event before
setting the object to nothing. The statement to set the object to nothing
should be the last line in the event procedure.
STATUS
Microsoft has confirmed this to be an issue in the Microsoft products
listed at the beginning of this article. Microsoft is researching this
problem and will post new information here in the Microsoft Knowledge Base
as it becomes available.
MORE INFORMATION
Steps to Reproduce Issue
- Start the 32-bit version of Visual Basic 4.0 or if it is already
running, click New Project on the File menu.
- Use the following steps to create a class module.
- Click Class Module on the Insert Menu. The code window for the class
module appears.
- In the Properties window of the Class1 class module, set the
Instancing Property to 2-Createable MultiUse, and the Public property
to True.
- Add the following code to the Class1 code window:
Option Explicit
Public Name As String
Private Sub Class_Terminate()
Form1.Print Name
End Sub
- Add the following code to the Form1 code window.
Option Explicit
Public A As New Class1
Private Sub Form_Load()
Show
Set A = New Class1
A.Name = "A"
'To workaround this bug, cut the next line
Set A = Nothing
Print "A Is " & IIf(A Is Nothing, "Nothing", "Something")
'And uncomment this next line.
'Set A = Nothing
End Sub
- Press the F5 key or click Start on the Run menu to run the program.
- Click Close from the Control Bar menu on the form. One of the following
application error displays and Visual Basic ends:
Windows NT 32-bit:
An application error has occurred and an application
error log is being generated, VB32.exe Exception: access
violation (0xc0000005), Address: 0x001d02d7.
-or-
VB32.EXE-Application Error dialog box. The instruction
at "0x001aaff8" referenced memory at "0x007dbd6b". The
memory could not be "written".
Windows 95 32-bit:
VB32 caused an invalid page fault in module <unknown> at
0000:a0000001.
|