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:

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
Close #1

Please note that I have NOT tested this code.

Hope this helps

Happy coding


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


I stand (sit) corrected... :)

Glad you could find the correct syntax for your controls.

Happy coding


Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.