Visual Basic Reference

Drive Property Example

This example displays a list of files for the current drive and directory. To try this example, paste the code into the Declarations section of a form that contains a DriveListBox control, a DirListBox control, and a FileListBox control, and then press F5. Use the mouse to change the drive or directory.

Private Sub Drive1_Change ()
   Dir1.Path = Drive1.Drive   ' When drive changes, set directory path.
End Sub
Private Sub Dir1_Change ()
   File1.Path = Dir1.Path   ' When directory changes, set file path.
End Sub