Use Path Property to Change File and Directory List Boxes

ID Number: Q86279

1.00

WINDOWS

Summary:

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. To change the contents of a file list

box or a directory list box properly, you have to set its Path

property instead.

This information applies to Microsoft Visual Basic programming system

version 1.0 for Windows.

More Information:

Steps to Reproduce Behavior:

----------------------------

1. 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.

2. Place a label (Label1), a file list box (File1), and a directory

list box (Dir1) on to Form1.

3. In the Form_Load event procedure, add the following code:

Sub Form_Load ()

ChDir "C:\DOS"

Label1.Caption = CurDir$

End Sub

4. Press F5 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.

5. From the Run menu, choose End. Press F5 to run the program again.

This time, the files listed are from the C:\DOS subdirectory.

Additional reference words: 1.00 1.0