Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Progress Bar to display total bytes "read"

Status
Not open for further replies.

Nicholas

IS-IT--Management
Feb 2, 2000
15
0
0
US
I am having programmatic amnesia! I cannot recall how to get the total file size and then diplay total bytes read &quot;so far&quot; using a progress bar.<br>
<br>
Any suggestions?<br>
<br>
Thanks much, <p>Nicholas, BofA NetOps<br><a href=mailto: Nick.deLioncourt@BankofAmerica.com> Nick.deLioncourt@BankofAmerica.com</a><br><a href= > </a><br>Biologically Tagged as Alpha-Geek #234
 
You'll want to use FileLen() function to get lenght of file in bytes.
Stated from Visual Basic 6 Complete

FileLen(filename)

The FileLen() function returns a long integer value indicating the file's lenght. The name of the file whose length you want to find out is passed as an argument to the fuction. The following statement
MsgBox FileLen(&quot;.\DOCS\MYDOCUMENT.TXT&quot;)
displays the lenght of the specifed file in a message box.
The FileLen() Function is different from the LOF() function, which returns the lenght of a file that has already been opened.

heres the code:

myfilelenght = FileLen(&quot;yourfile.txt&quot;)
progressbar1.max = myfilelenght

I don't know how you read a file byte by byte, but withing your loop add a byte counter, and withing the same loop set the progressbar1.value to equal that byte counter. So far I only read my files line by line, I set my progressbar1.max to the number of lines in a file, and then increase it by one in a loop when I read one more line.

Hope that helps. Email me if you want more info darkmercenary44@earthlink.net


DarkMercenary
DarkMercenary44@yahoo.com

In the real world

As in dreams

Nothing is quite

What it seems

:Book of Counted Sorrows
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top