Files & Folder ListBoxes
Again, both the file and folder list boxes have almost identical properties
to the listbox. You can get the selected items using the Selected property,
and set the selection using the ListIndex property. For more information
on these standard listbox properties, click here.
To set the path that the file lists the files from, simply set its
Path property. The following code sets the file list box to display
files in "C:Program Files"
Files1.Path = "C:Program Files"
To set the current folder for the folder listbox, or to change the
drive, you set the Path property, just like the file listbox:
'set the folder to C:Program Files
Dir1.Path = "C:Program Files"
'change to floppy
Dir1.Path = "A:"
However, you would obviously need to make sure there was a floppy in
Drive A before switching to it. The next section covers how to use the
three controls together, and shows you how to add some error handling
code to display a warning if there is no floppy in the drive, rather
than your program displaying an error message and quitting!