Checking disk in drive A:

I would like a VB code for the following pseudo code
 
 if no disk in drive A them
   msgBox ..
 end if

 if disk has problem(like unformated or damaged) then
    msgBox ..
 end if
g6yassinAsked:
Who is Participating?
 
anthonycConnect With a Mentor Commented:
try this:

on local error resume next
dim bAgain as boolean

do
  filecopy "c:\winnt\notepad.exe", "a:\notepad.exe"
  select case err
  case 71
     msgbox "Place a disk in drive A and try again"
     bAgain = true
  case 0
     bAgain = false
  case else
     msgbox error$
     bAgain = true
  end select
  err = 0
loop until not bAgain
0
 
subhashgargCommented:
How about
on error go to handle_err:

chdrive "a"
handle_err:
 if err = 68 then 'device unavailable
    msgbox

0
 
anthonycCommented:
that'll work too... Filecopy was just an example of the operation he was goign to perform.   I wouldn't use IF though.. Select Case is faster.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.