hello
i am trying to get a hard drives free and total space to display in a progressbar not sure what im doing wrong here any ideas?


Code:
Private Sub Form1_Load_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ProgressBar1.Maximum = NthField(FormatSize(HarddriveTotalFreeSpace), ".", 1) 'show left side of dots ..
ProgressBar1.Value = NthField(FormatSize(HarddriveAvailableFreeSpace), ".", 1)

'get the size
Label6.Text = NthField(FormatSize(HarddriveAvailableFreeSpace), ".", 1) + VBSpace + NthField(FormatSize(HarddriveAvailableFreeSpace), " ", 2)
End Sub
HarddriveAvailableFreeSpace and HarddriveTotalFreeSpace are the same size

Code:
Public VBSpace As String = " "

 Public Function HarddriveAvailableFreeSpace() As Long
        For Each curDrive As DriveInfo In My.Computer.FileSystem.Drives
            If curDrive.DriveType = DriveType.Fixed Then
                Dim theFreeSpace As Long = curDrive.AvailableFreeSpace
                Return theFreeSpace
            End If
        Next
    End Function

    Public Function HarddriveTotalFreeSpace() As Long
        For Each curDrive As DriveInfo In My.Computer.FileSystem.Drives
            If curDrive.DriveType = DriveType.Fixed Then
                Dim theFreeSpace As Long = curDrive.TotalFreeSpace
                Return theFreeSpace
            End If
        Next
    End Function

 Public Function FormatSize(ByVal BytesCaller As ULong) As String
        Dim DoubleBytes As Double

        Try
            Select Case BytesCaller
                Case Is >= 1099511627776
                    DoubleBytes = CDbl(BytesCaller / 1099511627776) 'TB
                    Return FormatNumber(DoubleBytes, 2) & " TB"
                Case 1073741824 To 1099511627775
                    DoubleBytes = CDbl(BytesCaller / 1073741824) 'GB
                    Return FormatNumber(DoubleBytes, 2) & " GB"
                Case 1048576 To 1073741823
                    DoubleBytes = CDbl(BytesCaller / 1048576) 'MB
                    Return FormatNumber(DoubleBytes, 2) & " MB"
                Case 1024 To 1048575
                    DoubleBytes = CDbl(BytesCaller / 1024) 'KB
                    Return FormatNumber(DoubleBytes, 2) & " KB"
                Case 0 To 1023
                    DoubleBytes = BytesCaller ' bytes
                    Return FormatNumber(DoubleBytes, 2) & " bytes"
                Case Else
                    Return ""
            End Select
        Catch
            Return ""
        End Try
    End Function

   Public Function NthField(ByVal expression As String, ByVal separator As String, ByVal fieldNum As Long) As String
        On Error Resume Next
        Dim fields() As String
        fields = Split(expression, separator, , vbTextCompare)
        NthField = fields(fieldNum - 1)
    End Function