Results 1 to 2 of 2

Thread: Im only want he cd to be displayed in the drivelistbox??

  1. #1

    Thread Starter
    Hyperactive Member Libero's Avatar
    Join Date
    Jun 2000
    Location
    Swedish viking
    Posts
    460
    Im only want he cd to be displayed in the drivelistbox?? Is there any way to manage this??

  2. #2
    Lively Member
    Join Date
    Jan 1999
    Location
    Lincolnshire, UK
    Posts
    111
    Fairly simple in VB6 (not sure about anything else)

    Add a list box called list1 and a drive box called drive1 to a form. In project->references tick the "Microsoft Scripting Runtime" reference and then add this code to your form

    Option Explicit

    Private Sub Form_Load()
    Dim Counter As Long
    Dim FS As New FileSystemObject
    'Loop through the available drives
    For Counter = 0 To Drive1.ListCount - 1
    'If the drive type is a CD then
    If FS.Drives(Left(Drive1.List(Counter), 1)).DriveType = CDRom Then
    'Add this to the Listbox
    List1.AddItem Drive1.List(Counter)
    End If
    'Next drive
    Next
    End Sub


    Cheers

    Chris

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