Results 1 to 9 of 9

Thread: Checking Whether Disk is in Floopy Drive

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2001
    Posts
    112

    Checking Whether Disk is in Floopy Drive

    Hi all,

    How can i check whether disk is in floppy drive?

    Thanks

  2. #2
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    The easiest way is to try to read it an trap its error.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  3. #3
    Hyperactive Member Dinz's Avatar
    Join Date
    Jan 2002
    Posts
    359
    Originally posted by Mc Brain
    The easiest way is to try to read it an trap its error.
    Thats a great idea..............
    !!!NobodyisPerfect......IamNOBODY!!!
    How's your wife and my kids?.....

    Never argue with an idiot. They drag you down to their level then beat you with experience!

    Child says : Mummy mummy, can i play with grandpa ?
    Mum says : NO, you have already dug him up twice.

    Galahtec The VB Forum

  4. #4
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    For example:
    VB Code:
    1. Option Explicit
    2.  
    3. Public Function IsDriveReady(Drive As String) As Boolean
    4.     Dim cDir As String
    5.     On Error GoTo NotReady
    6.    
    7.     IsDriveReady = True
    8.    
    9.     If Len(Drive) = 1 Then Drive = Drive & ":"
    10.     'Save the current dir
    11.     cDir = CurDir
    12.    
    13.     'Change the current dir to the drive we want to test
    14.     ChDir Drive
    15.    
    16.     'Change back to the path we were before
    17.     ChDir cDir
    18.    
    19.     On Error GoTo 0
    20.     Exit Function
    21.    
    22. NotReady:
    23.     If Err = 75 Then
    24.         'Path/File access error
    25.         IsDriveReady = False
    26.         Resume Next
    27.     End If
    28.  
    29. End Function
    30.  
    31. Private Sub Form_Load()
    32.     MsgBox IsDriveReady("A")
    33.    
    34.     'or
    35.    
    36.     MsgBox IsDriveReady("A:")
    37. End Sub
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  5. #5
    Banned
    Join Date
    Nov 2004
    Posts
    45

    Re: Checking Whether Disk is in Floopy Drive

    Quote Originally Posted by Mc Brain
    For example:
    VB Code:
    1. Option Explicit
    2.  
    3. Public Function IsDriveReady(Drive As String) As Boolean
    4.     Dim cDir As String
    5.     On Error GoTo NotReady
    6.    
    7.     IsDriveReady = True
    8.    
    9.     If Len(Drive) = 1 Then Drive = Drive & ":"
    10.     'Save the current dir
    11.     cDir = CurDir
    12.    
    13.     'Change the current dir to the drive we want to test
    14.     ChDir Drive
    15.    
    16.     'Change back to the path we were before
    17.     ChDir cDir
    18.    
    19.     On Error GoTo 0
    20.     Exit Function
    21.    
    22. NotReady:
    23.     If Err = 75 Then
    24.         'Path/File access error
    25.         IsDriveReady = False
    26.         Resume Next
    27.     End If
    28.  
    29. End Function
    30.  
    31. Private Sub Form_Load()
    32.     MsgBox IsDriveReady("A")
    33.    
    34.     'or
    35.    
    36.     MsgBox IsDriveReady("A:")
    37. End Sub
    How much of that code is really needed?

    Quote Originally Posted by Mc Brain
    For example:
    VB Code:
    1. Option Explicit
    2.  
    3. Public Function IsDriveReady(Drive As String) As Boolean
    4.     Dim cDir As String
    5.     On Error GoTo NotReady
    6.    
    7.     IsDriveReady = True
    8.    
    9. On Error GoTo 0
    10.     Exit Function
    11.    
    12. NotReady:
    13.     If Err = 75 Then
    14.         'Path/File access error
    15.         IsDriveReady = False
    16.         Resume Next
    17.     End If
    18.  
    19. End Function
    20.  
    21. statement
    Somthing like that?

  6. #6
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Checking Whether Disk is in Floopy Drive

    You still need to read the disk.


    Dir(Drive) would do it.

  7. #7
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808

    Re: Checking Whether Disk is in Floopy Drive

    Quote Originally Posted by the_inferno
    How much of that code is really needed?

    Somthing like that?
    Two things:

    a) I did not post the second snippet. I don't know why it says I originally posted.
    b) You stripped out all the lines which actually "checks" if the drive is ready.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  8. #8
    Banned
    Join Date
    Nov 2004
    Posts
    45

    Re: Checking Whether Disk is in Floopy Drive

    Quote Originally Posted by Mc Brain
    Two things:

    a) I did not post the second snippet. I don't know why it says I originally posted.
    b) You stripped out all the lines which actually "checks" if the drive is ready.
    Lol, damn!
    So how much do I really need?

  9. #9
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808

    Re: Checking Whether Disk is in Floopy Drive

    Quote Originally Posted by the_inferno
    Lol, damn!
    So how much do I really need?
    Could be...

    VB Code:
    1. Public Function IsDriveReady(Drive As String) As Boolean
    2.     Dim cDir As String
    3.     On Error GoTo NotReady
    4.    
    5.     IsDriveReady = True
    6.    
    7.     If Len(Drive) = 1 Then Drive = Drive & ":"
    8.     cDir = Dir(Drive)
    9.    
    10.     On Error GoTo 0
    11.     Exit Function
    12.    
    13. NotReady:
    14.     If Err.Number = 75 Then
    15.         'Path/File access error
    16.         IsDriveReady = False
    17.         Resume Next
    18.     ElseIf Err.Number = 52 Then
    19.         'Bad file name or number
    20.         IsDriveReady = False
    21.         Resume Next
    22.     End If
    23.  
    24. End Function
    25.  
    26. Private Sub Form_Load()
    27.     MsgBox IsDriveReady("A")
    28.    
    29.     'or
    30.    
    31.     MsgBox IsDriveReady("A:")
    32. End Sub
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

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