Microsoft KB Archive/86279

= PRB: ChDir or ChDrive Won't Change File / Directory List Boxes =

Article ID: 86279

Article Last Modified on 12/12/2003

-

APPLIES TO


 * Microsoft Visual Basic 2.0 Standard Edition
 * Microsoft Visual Basic 3.0 Professional Edition
 * Microsoft Visual Basic 2.0 Professional Edition
 * Microsoft Visual Basic 3.0 Professional Edition
 * Microsoft Visual Basic 1.0 Standard Edition

-



This article was previously published under Q86279





SYMPTOMS
Using the ChDir or ChDrive statement to change the current directory or drive does not change the listing of a file list box or a directory list box. However, the list changes if you run the program a second time in the VB.EXE environment.



RESOLUTION
To change the contents of a file list box or directory list box, set its Path property instead of using the ChDir or ChDrive statement.



STATUS
This behavior is by design.



Steps to Reproduce Behavior:
 Run Visual Basic, or from the File menu, choose New Project (ALT, F, N) if Visual Basic is already running. Form1 is created by default. Place a label (Label1), a file list box (File1), and a directory list box (Dir1) on to Form1.  In the Form_Load event procedure, add the following code: Sub Form_Load ChDir &quot;C:\DOS&quot; Label1.Caption = CurDir$ End Sub  Press the F5 key to run the program. The label will display &quot;C:\DOS&quot;, but the files listed are still those from the directory where Visual Basic was started. From the Run menu, choose End. Press the F5 key to run the program again. This time, the files listed are from the C:\DOS subdirectory.</li></ol>

Additional query words: 2.00 3.00

Keywords: kbprb KB86279

-

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

© Microsoft Corporation. All rights reserved.