Program crashed after selecting floppy drive, CD-ROM drive, Zip drive that didn't have disk in 
Author Message
 Program crashed after selecting floppy drive, CD-ROM drive, Zip drive that didn't have disk in

How to make my app to handle when I select a drive with the Drive list box
but no disk is in?

Clarence : )
--
If reply via e-mail, please take off the 'A' from the address.



Sun, 10 Oct 1999 03:00:00 GMT  
 Program crashed after selecting floppy drive, CD-ROM drive, Zip drive that didn't have disk in


04:46:36 GMT):

Quote:
>How to make my app to handle when I select a drive with the Drive list box
>but no disk is in?

Sub Drive1_Change ()
Static OldDrive As String

On Error GoTo ErrHandler
Dir1.Path = Drive1.Drive
OldDrive = Drive1.Drive
Exit Sub

ErrHandler:
MsgBox "Error: " & Error$(Err)
Drive1.Drive = OldDrive
Resume

End Sub

Mathias Schiffer, Germany
-----------------------------------------------
VB-FAQ: http://home.sol.no/jansh/vb/default.htm
NG-tips: http://www.rat.de/metty/vbnews



Sun, 10 Oct 1999 03:00:00 GMT  
 Program crashed after selecting floppy drive, CD-ROM drive, Zip drive that didn't have disk in

Quote:

> How to make my app to handle when I select a drive with the Drive list box
> but no disk is in?

Use ON ERROR to handle the error that occurs when you select the empty
disk drive.

--

Get PR-Tracker -- Tracks problem reports (bugs, defects)
INFORMATION  http://www.halcyon.com/softwise/prtracker.html
DOWNLOAD     http://www.halcyon.com/softwise/download.html
TECH SUPPORT http://www.halcyon.com/softwise/TechSupport.html



Sun, 10 Oct 1999 03:00:00 GMT  
 Program crashed after selecting floppy drive, CD-ROM drive, Zip drive that didn't have disk in

Put an error handler in the code that checks for the specific error code
generated when the disk is not there:

Private Sub DriveDiskette_Change()
    On Error GoTo DriveDiskette_Change_error
    Dim lans As Long

    DirDiskette.Path = DriveDiskette.Drive

    Exit Sub
DriveDiskette_Change_error:
    If Err = 68 Then
      lans = MsgBox("Cannot read drive " & DriveDiskette.Drive _
        & Chr(10) & "Make sure that the drive door is closed " _
        & "and that the disk is formatted and free of errors." _
        , vbRetryCancel, "Which Drive?")
      If lans = vbRetry Then
        Resume
      Else
        Exit Sub
      End If
    End If
    gblsubError ("DriveDiskette_Change_error")
    Exit Sub

End Sub



Quote:
> How to make my app to handle when I select a drive with the Drive list
box
> but no disk is in?

> Clarence : )
> --
> If reply via e-mail, please take off the 'A' from the address.




Sun, 10 Oct 1999 03:00:00 GMT  
 Program crashed after selecting floppy drive, CD-ROM drive, Zip drive that didn't have disk in

Quote:

>Sub Drive1_Change ()
>Static OldDrive As String
>On Error GoTo ErrHandler
>Dir1.Path = Drive1.Drive
>OldDrive = Drive1.Drive
>Exit Sub
>ErrHandler:
>MsgBox "Error: " & Error$(Err)
>Drive1.Drive = OldDrive
>Resume
>End Sub

I usually do:

Sub Drive1_change()
        on error goto fail
        dir1.path=drive1.drive
        exit sub
fail:
        msgbox Error$,48,"ERROR"
        drive1.drive=dir1.path
        exit sub
end Sub

Just a subtle difference, but a little simpler.

Gent (Ghent, Gand),
Belgium,
Europe,
3rd planet from the sun.



Sun, 10 Oct 1999 03:00:00 GMT  
 Program crashed after selecting floppy drive, CD-ROM drive, Zip drive that didn't have disk in

Don't use the DriveListBox
copy the contens of a DriveListBox to a ComboBox and then handle the
error



Sat, 16 Oct 1999 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Checking Whether Drive is a CD ROM Drive

2. Retrieving drive letter for user's cd-rom drive

3. How to determine if a drive is a CD-ROM drive

4. Determining if a Network Drive is a CD-ROM drive

5. Determining if a Network Drive is a CD-ROM drive

6. Select CD-ROM Drive...

7. Insert records from a database in floppy drive to hard drive

8. Determining drive letter assigned to floppy drive?

9. check is there a CD ROM in the CD drive

10. Use 2nd CD-ROM drive to play CD Audio

11. enumerate cd-rom drives

12. VBA reference to Cd-ROM drive

 

 
Powered by phpBB® Forum Software