PRB: ChDir or ChDrive Won't Change File / Directory List Boxes
ID: Q86279
|
The information in this article applies to:
-
Microsoft Visual Basic Standard and Professional Editions for Windows, versions 2.0, 3.0
-
Microsoft Visual Basic programming system for Windows, version 1.0
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.
MORE INFORMATIONSteps 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 "C:\DOS"
Label1.Caption = CurDir$
End Sub
- Press the F5 key to run the program. The label will display "C:\DOS",
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.
Additional query words:
2.00 3.00
Keywords :
Version :
Platform :
Issue type :
|