How to Create a Directory List Box in Visual Basic

Written by ehow contributor
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Create a Directory List Box in Visual Basic
(Jupiterimages/ Images)

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:


  1. 1

    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.

  2. 2

    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.

  3. 3

    Click on the interior of the frame. This will allow you to move the position of the frame by dragging it around the screen.

  1. 1

    Click on the directory list box a single time. This allows you to select the box.

  2. 2

    Browse the properties window. There are two columns, one for names and one for values. Find the "Name" property.

  3. 3

    Click in the column next to "Name," and type in the word you will be using to identify your directory list box.

  4. 4

    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.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.