Progress Bar

kb2tfa

New member
Joined
Jan 10, 2008
Messages
4
Programming Experience
1-3
I cannot get this code to work, can someone look at it?

I do get values from this with the messagebox, but not with the progress bar.



VB.NET:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        Dim HDTotalSIZE As Integer = My.Computer.FileSystem.Drives(1).TotalSize
        ProgressBar2.Maximum = HDTotalSIZE

        Dim HDAvailSIZE As Integer = My.Computer.FileSystem.Drives(1).AvailableFreeSpace
        ProgressBar2.Value = HDAvailSIZE

        Button2.Enabled = False

    End Sub
 
Last edited by a moderator:
TotalSize and AvailableFreeSpace are Long type numbers, they are too big for Progressbar. Calculate percentage and use default Progressbar max of 100. Example:
VB.NET:
Dim info As IO.DriveInfo = My.Computer.FileSystem.Drives(0)
ProgressBar1.Value = info.AvailableFreeSpace / info.TotalSize * 100
 
No, it give you what you wanted to display in progressbar; available in relation to total.
 
Back
Top