Visual Basic forms often make users choose a file from their computers' hard drive. The directory list box control, along with the drive list and file list controls, make that process relatively easy. The directory list box's function is to allow the user to specify a certain directory, presumably for opening or saving a file located there.
- Skill level:
Other People Are Reading
Hover the mouse over each tool in the Toolbox palette until you find the one called "DirectoryListBox" (its name will pop up on the side as a yellow tag). Double-click the "DirectoryListBox" tool once you've found it.
Use the resizing handles (the small squares around the box's perimeter) to stretch or shrink the directory list box's size. Realize that you can only change the width, not the height, of your directory list box.
Click on the interior of the frame. This will allow you to move the position of the frame by dragging it around the screen.
Click on the directory list box a single time. This allows you to select the box.
Browse the properties window. There are two columns, one for names and one for values. Find the "Name" property.
Click in the column next to "Name," and type in the word you will be using to identify your directory list box.
Use a standard name that starts with "dir" and is then followed by a capitalized short word that describes the directory list box's function. You might, for example consider naming a directory list box that is used to save a file, "dirSave."
Tips and warnings
- This control is perfect for forms that are used to emulate an "Open File" or "Save File" function.
- After the directory list box is created, you can read its value in code by referring to its "Path" property (for example, msgbox dirSave.Path)
- Do realize that this control will actually change the active directory just because you create it. You are still required to write code if you want files from the selected directory to appear.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for