progressbat control example

  • Thread starter Thread starter Reny J Joseph Thuthikattu
  • Start date Start date
R

Reny J Joseph Thuthikattu

Hi,
i want to implement a progress bar control when reading a file.Can any one
tell me how do i do that?
Reny
 
Hi Reny,

If its a text file you could count the number of lines on
it. Then You open it and read line by line and increase
the value and the maximum would be the number of lines.

Kind Regards
Jorge
 
* "Reny J Joseph Thuthikattu said:
i want to implement a progress bar control when reading a file.Can any one
tell me how do i do that?

Sample (untested):

\\\
Dim s As New System.IO.BinaryReader(New System.IO.FileStream("C:\WINDOWS\WIN.INI", IO.FileMode.Open))
Dim t() As Byte ' Buffer.
Me.ProgressBar1.Minimum = 0
Me.ProgressBar1.Maximum = s.BaseStream.Length
Dim BytesRead As Long
Dim WholeFile As New System.Text.StringBuilder
While BytesRead < s.BaseStream.Length
t = s.ReadBytes(32) ' Specify number of bytes to be read here.
WholeFile.Append(System.Text.Encoding.Default.GetString(t))
BytesRead = BytesRead + t.Length
Me.ProgressBar1.Value = BytesRead
Threading.Thread.Sleep(100) ' For test purposes.
End While
s.Close()
MsgBox(WholeFile.ToString() & "|")
///
 
Back
Top