Drive Combo, Folder and File List Controls

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!

You might also like...

Comments

About the author

James Crowley

James Crowley United Kingdom

James first started this website when learning Visual Basic back in 1999 whilst studying his GCSEs. The site grew steadily over the years while being run as a hobby - to a regular monthly audien...

Interested in writing for us? Find out more.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Better train people and risk they leave – than do nothing and risk they stay.” - Anonymous