Make your own free website on

Synchronize Drive, Dir And File List Boxes

'Add Drive List Box, Dir List Box and File List Box to your Form.
'The following code also avoid errors when the user choose Invalid Drive
'(Device Not Ready Error).
'Insert the following code to your form:

Dim DriveTemp As Integer
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub

Private Sub Drive1_Change()
On Error GoTo ErrorHandler
Dir1.Path = Drive1.Drive
DriveTemp = Drive1.ListIndex
Exit Sub
Drive1.ListIndex = DriveTemp
End Sub

Private Sub Form_Load()
DriveTemp = Drive1.ListIndex
End Sub

Go Back