新建From1,新建Drive1(DriveListBox),Dir1(DirListBox),File1(FileListBox)代码:
Private Sub Dir1_Change()
'当目录发生改变时使File1也随之改变
'以便显示该目录中的文件
File1.Path = Me.Dir1.Path
End Sub
Private Sub Drive1_Change()
'当驱动器发生改变时使Dir1与其保持一致
On Error GoTo IFerr '拦截错误
Dir1.Path = Drive1.Drive
Exit Sub
IFerr: '如果磁盘错误
MsgBox "请确认驱动器是否准备好或者磁盘已经不可用!", vbOKOnly + vbExclamation
Drive1.Drive = Dir1.Path '忽略驱动器改变
Exit Sub
End Sub
Private Sub Form_Load()
End Sub