DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Visual Basic 4 / 5 / 6 (http://www.daniweb.com/forums/forum4.html)
-   -   progress bar problem in vb (http://www.daniweb.com/forums/thread38562.html)

jto Jan 23rd, 2006 10:16 am
progress bar problem in vb
 
hi,
i am using a progress bar in a conversion program in conversion process progress bar is showing the progress of conversion , but i am using a timer increment for increase the progress bar , but when file is big due to timer is showing the process has been completed but actually file conversion is not completed .Is at any method is there which can calculate the first file size and according to this file size process gets incerement . :confused:

Yomet Jan 25th, 2006 10:26 pm
Re: progress bar problem in vb
 
Hi jto,

If I understand correctly you are loading a file and want the progress bar to indicate how far you have actually come in the load process - correct?

If so you could use the FileLen(<path>) function to get the length of the file initially. You store this in the MaxValue of the progress bar and keep a 'counter' to track how much of the file you have read so far by adding the length of the data you just read to it every time you do an input. Something like this:
Dim BytesRead As Long
Dim InputLine As String

ProgressBar.MinValue = 0
ProgressBar.MaxValue = FileLen(<path>)
Open <path> For Input As #1
While Not EOF(1)
  LineInput #1, InputLine
  BytesRead = BytesRead + Len(InputLine)
  ProgressBar.Value = BytesRead
Wend
Close #1
Please note that I have NOT tested this code.

Hope this helps

Happy coding

Yomet

jto Jan 31st, 2006 10:13 am
Re: progress bar problem in vb
 
thank u yomet
this working right , but in this progressbar.minvalue is not true command it should be progressbar.min=0 and progressbar.max=0

Yomet Feb 2nd, 2006 11:54 pm
Re: progress bar problem in vb
 
jto,

I stand (sit) corrected... :)

Glad you could find the correct syntax for your controls.

Happy coding

Yomet


All times are GMT -4. The time now is 11:35 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC