+ Reply to Thread
Results 1 to 9 of 9

code to check a: drive has a disk in

Hybrid View

  1. #1
    Forum Contributor funkymonkUK's Avatar
    Join Date
    01-07-2005
    Location
    London, England
    Posts
    500

    code to check a: drive has a disk in

    hi

    How do i ensure that the user has put a disk in the drive. I have an msgbox which pops up telling them to put a disk in before contiuning however if their is no disk in it throughs out a debug.

  2. #2
    Forum Contributor
    Join Date
    06-10-2004
    Location
    India
    Posts
    1,066
    This worked for me.


    Sub test()

    On Error GoTo MY
    MyNAme = Dir("A:\")
    Exit Sub

    MY:
    MsgBox "Please insert disk in A:"

    End Sub



    Mangesh

  3. #3
    Forum Contributor funkymonkUK's Avatar
    Join Date
    01-07-2005
    Location
    London, England
    Posts
    500
    that worked but how do i loop that until there is a disk in there?

  4. #4
    Forum Contributor
    Join Date
    06-10-2004
    Location
    India
    Posts
    1,066
    Again, this worked for me:


    Private Sub CommandButton1_Click()

    ny:
    a = test
    If a = 1 Then
    MsgBox "Insert disk"
    GoTo ny
    End If

    End Sub

    Function test()
    On Error GoTo my
    test = Dir("A:\")
    Exit Function

    my:
    test = 1

    End Function



    Mangesh

  5. #5
    Forum Contributor funkymonkUK's Avatar
    Join Date
    01-07-2005
    Location
    London, England
    Posts
    500
    i am having problems trying to implement within my code because of the function could you tell me abit more about functions?

  6. #6
    Forum Contributor
    Join Date
    06-10-2004
    Location
    India
    Posts
    1,066
    In your code, when you want to check the A: part, simply use:

    ny:
    a = test
    If a = 1 Then
    MsgBox "Insert disk"
    GoTo ny
    End If


    When your code is over, put the function in the earlier post.



    Mangesh

  7. #7
    Forum Contributor funkymonkUK's Avatar
    Join Date
    01-07-2005
    Location
    London, England
    Posts
    500
    thanks for thank however i know the user has an A: drive I just need to know how to check if the disk is in anf if not bring out an error message and do so until a disk has been inserted.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1