Results 1 to 7 of 7

Thread: is there a disk in the floppy drive??

  1. #1

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604
    Hi.
    I know I'm just full of questions today.

    Does anybody know if there is a way to check whether or not there is a floppy disk in the drive without asking for a specific filename??


  2. #2
    Fanatic Member Dim's Avatar
    Join Date
    Jul 2000
    Posts
    620
    I'm sure there is...but you can simply ask for A:\ and have some kind of external error handling when windows replys that there is not disk.
    Or just goto http://www.vb-world.net/tips/tip99.html it has info on checking if a cd is in...so just chnage some values and that should do it..

    gl,
    D!m
    Dim

  3. #3
    Guest
    Code:
    On Error Resume Next 'keep going on error
    For i = 1 To 2 '2 times is enough
      Open "a:\" For Random As #1 'open the a: drive
             Close #1 'close the a: drive
        Next 'do it again
    Work with that code...it may get you somewhere in life.

  4. #4

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604

    sorry more help please

    Hi.

    Thanks both for the help

    I wonder if this makes sense:

    If there is a floppy disk in A: Then ( Do This)
    Else (Do Nothing)


    I am trying to figure out how to make this work but I really dont know how to do error handling.

    Further patience and suggestions are appreciated.
    THanks

  5. #5
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845

    Code:
    Private Sub Command1_Click()
    
    If DiskInDrive() Then
      MsgBox "There seems to be a disk in A: drive"
    Else
      MsgBox "There doesn't seem to be a disk in A: drive"
    End If
    
    
    End Sub
    
    Function DiskInDrive() As Boolean
    On Error GoTo ErrHan
      Dir "a:\", vbDirectory
      
      DiskInDrive = True
    Exit Function
    
    ErrHan:
      DiskInDrive = False
    
    End Function
    Mark
    -------------------

  6. #6
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Talking Error handling quick intro to help U

    Try this code at the beginning of the procedure, say on a button click:

    Sub CmdButton1_Click()

    On error goto BuggerIt

    Open "a:\" For Random As #1

    BuggerIt :
    If err.number = 71 then
    MsgBox”no disk in drive A”
    End If

    End Sub

    When you get an error message appear on your screen, it normally has a number (as above no disk in your drive when accessing it, occurs an error 71). At the start, on error goto yourname, says to VB "ok, if you get an error, goto the bottom of the page.

    At the bottom, you can use the err.number, to see what error has ocurred and deal with that specifically.

    With your project this is handy as whether the error is no disk in drive, or cannot find a file on the disk, you are going to have the same message appear, using the err.number (number of the error) you can separate these.

    Alex Read

  7. #7
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    event code:
    Code:
    on error goto errHandler:
     Dir "A:\"
    
    'bla bla
    errHandler:
     if error = 52 then
       msgbox "please load your disk in drive a:\"
     endif
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width