Results 1 to 5 of 5

Thread: drive letter

  1. #1
    Join Date
    Oct 2004
    Posts
    57

    Unanswered: drive letter

    I need a message box to display the drive letter the following server is mapped to:

    \\Csc_mdfs1\COMMON1

    on my pc its linked to the J: drive, but this program will run on several different pc's.

    I tried the driveletter function, but i can't seem to get it to work.
    any thoughts?
    thanks

  2. #2
    Join Date
    Mar 2004
    Location
    belgium
    Posts
    290
    this may be any help

    Sub ShowDriveLetter(drvPath)
    Dim fs, d, s
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set d = fs.GetDrive(fs.GetDriveName(drvPath))
    s = "Drive " & d.DriveLetter & ": - "
    s = s & d.VolumeName & vbCrLf
    s = s & "Free Space: " & FormatNumber(d.FreeSpace/1024, 0)
    s = s & " Kbytes"
    MsgBox s
    End Sub

  3. #3
    Join Date
    Mar 2004
    Location
    belgium
    Posts
    290
    this one is better

    Private Sub ShowDriveLetter(drvPath)
    Dim fs, d, dc, s, n
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set dc = fs.Drives
    For Each d In dc
    s = s & d.DriveLetter & " - "
    If s <> "A" Then
    If d.DriveType = 3 Then
    n = d.ShareName
    Else
    n = d.VolumeName
    End If
    End If

    s = s & n & vbCrLf
    Next
    MsgBox s

    End Sub

  4. #4
    Join Date
    Oct 2004
    Posts
    57
    I'm getting a blank....is there anyway to show current directory?

  5. #5
    Join Date
    Jul 2004
    Location
    Inverurie
    Posts
    628
    Try this:

    Code:
    ‘Gets the root of the disk drive specified in the passed path.
    ‘ie:  C:\
    
    Public Function GetDrivePath (PathStrg As String) As String
    
    	On Error Resume Next
    	GetDrivePath = Left$(Trim(PathStrg), 2)
    	If Right$(GetDrivePath, 1) <> “:”  or Err <> 0 Then GetDrivePath = “”: Exit Function
    	GetDrivePath = GetDrivePath & “\”
    
    End Function

Posting Permissions

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