Traping Error number 68??
hi
i have a drivelistbox ,dirlistbox and filelistbox
i want to trap error( Device unavailable "68")
i placed the following code
VB Code:
Private Sub Drive1_Change()
On Error GoTo EH:
EH:
If err.Number = 68 Then
GoTo DISK
End If
DISK:
MsgBox "Drive A:\ is Not Ready"
Drive1.Drive = "C:\"
Exit Sub
Dir1.Path = Drive1.Drive
End Sub
when i run the program the error occured on clicking any drive(all drives)
what i have to do?
THANKS
Re: Traping Error number 68??
Try This
Private Sub Drive1_Change()
On Error GoTo EH:
Dir1.Path = Drive1.Drive
Exit Sub
EH:
If err.Number = 68 Then
GoTo DISK
End If
DISK:
MsgBox "Drive A:\ is Not Ready"
Drive1.Drive = "C:\"
End Sub
Re: Traping Error number 68??
@Nida, That wont work as if you hit an error that is not 68 or no error at all it will still fall through and run the DISK subroutine because there is no Else condition or exit sub condition before the msgbox code.
Re: Traping Error number 68??
@binilmb, your msgbox will always fire even if the error is not 68.
VB Code:
Private Sub Drive1_Change()
On Error GoTo EH:
Dir1.Path = Drive1.Drive
Exit Sub
EH:
If err.Number = 68 Then
MsgBox "Drive A:\ is Not Ready"
Else
MsgBox Err.Number & " - " & Err.Description
End If
Drive1.Drive = "C:\"
End Sub