visual basic small but big problem

Status
Not open for further replies.

amandeep2707

Right off the assembly line
i have visual studio 6.
i designed a program to browse drives.

here's the problem:
the drive list box shows all drives(including cd drives and floppy drive). but if i try to access a floppy drive or a cd drive in which no media is present, then i get an error message saying that
the given device is unavailable and the program shuts down. how do i bypass this so that this error does not occur(or displays a message in a message box) and the program also does not shut down??

please help
 

Digit_Dragon

Old Stock in New Bottle!!
The program shuts down, may be for the the reason, if one attempts to access the property without sufficient permission that throws a SecurityException.
 

abhijangda

Padawan
This is because no media is present. You can change this error to display a message box. You can download this Accessdrive.zip and extract it to any location say C:\accessdrive. It will have a .frm file run it you can get the code in drvDriveBox. Replace the errornumber with your own error number if needed and you can also change the Message.
 

plsoft

Journeyman
If u face this problem only when there is no media then this code might help. Handle the errors by including the following code:
Private Sub...............
On Error GoTo drvError 'drvError or any error name you want
{statements}
{statements}
{statements}
drvError:
MsgBox "There is no media in the drive"
Exit Sub
End Sub

Hope this helps
 
Status
Not open for further replies.
Top Bottom