When I Choose The Option D:\ (CD Drive) and there is no Cd in the drive i get an error message,
is there a way to make it do nothing
Thanx
Lavarock09
Printable View
When I Choose The Option D:\ (CD Drive) and there is no Cd in the drive i get an error message,
is there a way to make it do nothing
Thanx
Lavarock09
Just by selecting it in the drive list box won't cause an error. In the code where you try to access the drive, you need to have an error handler.
Kinda like this :
VB Code:
Private Sub SomeSub() On Error GoTo ErrHandler If Drive1.Drive = "e:" Then 'do whatever that might cause an error End If ErrHandler: Exit Sub End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
this is where you error is most likely being generated, when it update a directory listbox
pete
i want it so that if there is a cd in drive d: or a Zip Disk in Drive E: it will show it in the Directory list and if there isn't a cd/Zip disk in there it will say in a msgbox, the drive is empty
i have already got the C: drive to show in the directory list, and i have put a zip disk in and have looked a the files in the directory list from that,
can you help
Private Sub Drive1_Change()
On Error Resume Next
Dir1.Path = Drive1.Drive
End Sub
this will remove the error you get, if there is an error it just skips it,
in most cases not good practice, but probaly ok for this,
so if no cd in drive, although drive box will show "D" directory list will still be from previous
pete
Thanx, Problem Fixed