Microsoft KB Archive/197126

= BUG: IPF Referencing Default Property of Nonexistent Image Ctrl =

Article ID: 197126

Article Last Modified on 5/12/2003

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q197126



SYMPTOMS
When you try to access the default property of a nonexistent Image Control in a control array in Visual Basic 6.0, an Invalid Page Fault (IPF) or application error occurs instead of a run-time error.



RESOLUTION
Specify the Picture property of the Image1.Picture explicitly, instead of depending on the default property.



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.



Steps to Reproduce Behavior
 Create a new Standard EXE Project. Form1 is created by default. Place an Image Control on Form1. Set the Index Property of the Image Control to "0."  Add the following code in the General Declarations section of Form1: Private Sub Form_Load Dim p As StdPicture Set p = Pic End Sub

Private Function Pic As StdPicture Set Pic = Image1(1) ' NOTE THAT IMAGE1(1) DOESN'T EXIST! End Function  Press the F8 key to start the project. Press F8 to step through the project. Close Form1.</li> Repeat steps 5 and 6 several times to get the IPF.</li>  To avoid the page fault, specify Image1(1).Picture explicitly instead of depending on the default property. So, repeat steps 1 through 4, replacing the Pic Function with the following: Private Function Pic As StdPicture Set Pic = Image1(1).Picture End Function </li> Run the project.</li></ol>

RESULT: Notice that it throws the following error as expected, because the array element specified by the index does not exist:

Run-time Error '340:

Control array element '1' doesn't exist

Additional query words: GPF IPF

Keywords: kbbug kbctrl kbpending KB197126

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.