Results 1 to 6 of 6

Thread: Drive List Help [RESOLVED]

  1. #1

    Thread Starter
    Lively Member lavarock09's Avatar
    Join Date
    Jun 2005
    Posts
    124

    Drive List Help [RESOLVED]

    When I Choose The Option D:\ (CD Drive) and there is no Cd in the drive i get an error message,

    is there a way to make it do nothing

    Thanx

    Lavarock09
    Last edited by lavarock09; Jun 18th, 2005 at 05:30 AM.

  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Drive List Help

    Just by selecting it in the drive list box won't cause an error. In the code where you try to access the drive, you need to have an error handler.

    Kinda like this :

    VB Code:
    1. Private Sub SomeSub()
    2.     On Error GoTo ErrHandler
    3.     If Drive1.Drive = "e:" Then
    4.         'do whatever that might cause an error
    5.     End If
    6.    
    7. ErrHandler: Exit Sub
    8. End Sub


    Has someone helped you? Then you can Rate their helpful post.

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Drive List Help

    Private Sub Drive1_Change()
    Dir1.Path = Drive1.Drive
    End Sub

    this is where you error is most likely being generated, when it update a directory listbox

    pete

  4. #4

    Thread Starter
    Lively Member lavarock09's Avatar
    Join Date
    Jun 2005
    Posts
    124

    Re: Drive List Help

    i want it so that if there is a cd in drive d: or a Zip Disk in Drive E: it will show it in the Directory list and if there isn't a cd/Zip disk in there it will say in a msgbox, the drive is empty

    i have already got the C: drive to show in the directory list, and i have put a zip disk in and have looked a the files in the directory list from that,

    can you help

  5. #5
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Drive List Help

    Private Sub Drive1_Change()
    On Error Resume Next
    Dir1.Path = Drive1.Drive
    End Sub

    this will remove the error you get, if there is an error it just skips it,
    in most cases not good practice, but probaly ok for this,
    so if no cd in drive, although drive box will show "D" directory list will still be from previous

    pete

  6. #6

    Thread Starter
    Lively Member lavarock09's Avatar
    Join Date
    Jun 2005
    Posts
    124

    Re: Drive List Help

    Thanx, Problem Fixed

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