Microsoft KB Archive/257686

= FIX: Double-Clicking ListBox Control Causes Invalid Page Fault =

Article ID: 257686

Article Last Modified on 8/7/2007

-

APPLIES TO

 Microsoft Visual Basic 6.0 Learning Edition, when used with:  Microsoft Windows 95

 Microsoft Windows 98 Standard Edition

 Microsoft Windows Millennium Edition  Microsoft Visual Basic 6.0 Professional Edition, when used with:  Microsoft Windows 95</li></ul>

 Microsoft Windows 98 Standard Edition</li></ul>

 Microsoft Windows Millennium Edition</li></ul> </li> Microsoft Visual Basic 6.0 Enterprise Edition, when used with:  Microsoft Windows 95</li></ul>

 Microsoft Windows 98 Standard Edition</li></ul>

 Microsoft Windows Millennium Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q257686

<div class="symptoms_section">

SYMPTOMS
In a case where you have a form with a ListBox control and you are populating the list from a database, if you unload the form in the double-click event of the ListBox control, an Invalid Page Fault occurs.

<div class="status_section">

STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected in the latest service pack for Visual Studio 6.0.

For additional information about Visual Studio service packs, click the following article numbers to view the articles in the Microsoft Knowledge Base:

194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why

194295 HOWTO: Tell That a Visual Studio Service Pack Is Installed

To download the latest Visual Studio service pack, visit the following Microsoft Web site:

http://msdn2.microsoft.com/en-us/vstudio/Aa718353.aspx

<div class="moreinformation_section">

MORE INFORMATION
The following steps use the Biblio database. They assume that the database is located in the default Visual Basic installation path:

C:\Program Files\Microsoft Visual Studio\Vb98\Biblio.mdb

Steps to Reproduce Behavior
<ol> Start a new Standard EXE project in Visual Basic. Form1 is created by default.</li> On the Project menu, select References. On the References dialog box, check Microsoft ADO 3.51 Object Library, and then click OK.</li>  On the Project menu, add a new module, and then insert the following code: Option Explicit

Public MainDatadb As Database </li> <li>Add a Command Button to Form1.</li> <li> Add the following code to the code window of Form1: Option Explicit

Private Sub Command1_Click Form2.ShowMeGeneral MainDatadb, "Authors", "Author", "AU_id",, _ "Find an author", "au_id" End Sub

Private Sub Form_Load Dim DBName As String

' Change the following path if necessary for your system DBName = "C:\Program Files\Microsoft Visual Studio\VB98\BIBLIO.MDB" Set MainDatadb = OpenDatabase(DBName, False, False) End Sub </li> <li>On the Project menu, add a second form, Form2, to the project.</li> <li>Add a ListBox control to Form2.</li> <li> Add the following code to the code window of Form2: Option Explicit

Public SelectedValue As String Public KeyValue As String Public Canceled As Boolean

Public Sub ShowMeGeneral(DBName As Database, DBTable As String, _ FldDisplay As String, FldReturn As String, Optional InSql As Variant, _ Optional Title As Variant, Optional KeyField As Variant)

Dim Sql As String, TempRS As Recordset Dim Indx As Integer, TmpString As String Dim DisplayString As String If IsMissing(InSql) Then Sql = "SELECT [" & FldDisplay & "],[" & FldReturn & "] " & _ "FROM " & DBTable & " ORDER BY [" & FldDisplay & "];" Else Sql = InSql End If   Set TempRS = DBName.OpenRecordset(Sql,, dbReadOnly) Do Until Indx > 5000 DisplayString = TempRS(FldDisplay) & "" DisplayString = "abcdefghijklmm" & Indx List1.AddItem DisplayString Indx = Indx + 1 TempRS.MoveNext Loop TempRS.Close Set TempRS = Nothing List1.ListIndex = 0 Canceled = True Me.Show vbModal End Sub

Private Sub List1_DblClick Unload Me End Sub </li> <li>Run the project and click on Command1 to open Form2.</li> <li>Double-click on an item in the ListBox control on Form2. The result should be an Invalid Page Fault.</li></ol>

Additional query words: sp4 IPF GPF

Keywords: kbbug kbctrl kbfix kblistbox kbvs600sp4fix kbvs600sp5fix KB257686

-

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

© Microsoft Corporation. All rights reserved.