Guaranteed Hits to your web site!












Learn Visual Basic 6.0


4. More Exploration of the Visual Basic Toolbox


Synchronizing the Drive, Directory, and File List Boxes

  1. The drive, directory, and file list boxes are almost always used together to obtain a file name. As such, it is important that their operation be synchronized to insure the displayed information is always consistent.

  2. When the drive selection is changed (drive box Change event), you should update the directory path. For example, if the drive box is named drvExample and the directory box is dirExample, use the code:

  3. Notice what happens as you resize the two boxes. Notice the layer effect when you move one box on top of the other. Notice the effect of the image box Stretch property. Play around with different file types - what differences do you see?
  4. When the directory selection is changed (directory box Change event), you should update the displayed file names. With a file box named filExample, this code is:
  5. Once all of the selections have been made and you want the file name, you need to form a text string that correctly and completely specifies the file identifier. This string concatenates the drive, directory, and file name information. This should be an easy task, except for one problem. The problem involves the backslash (\) character. If you are at the root directory of your drive, the path name ends with a backslash. If you are not at the root directory, there is no backslash at the end of the path name and you have to add one before tacking on the file name.

  6. Example code for concatenating the available information into a proper file name and then loading it into an image box is:
    Note we only use properties of the file list box. The drive and directory box properties are only used to create changes in the file list box via code.


Pen Line


Counter Hit Counter Hit


This Homepage is special brought to you by CK Tan
Hosted by www.Geocities.ws

1