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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loading A File Takes Time!

Status
Not open for further replies.

MrVB50au

Programmer
Mar 16, 2003
326
AU
I'm loading a file in my application but it seems to take 6 seconds in doing so.

I want to use a progress bar showing the user that it is processing instead of them thinking that it had stopped working or had frozen.

Does anyone have an idea of how I'm able to calculate this time and/or any other variable time to use in the Progressbar1 control?

Thanks for your time,

Andrew.
 
I'm not sure what you mean by loading a file but for progress bars in running Excel sheets I get the .recordcount, divide by 20, and increment by that. If you have a record count before loading (perhaps from the query or whatever) maybe you can use that.
 
A file I'm talking about has to be loaded that IS NOT A data file, the datafile is simple to calculate, I'm talking about something in the line of getting the time it takes by the CPU. It's ok tho' I have worked out away by starting an avi file before the process and ending it after the processing had been done.

Thanks anyway, very much appreciate your reply,

Andrew.
 

If it is just a text file that you would normally input via Line Input then you can do something like...
[tt]
Private Sub ProcessFileContents(strFileName As String)

On Error GoTo ProcessFileContentsError

Dim FName As String, FNumb As Integer, FileContentsString As String, FileContentsArray() As String
Dim NumberOfLinesToProcess As Integer, I As Integer

FName = strFileName
FNumb = FreeFile

'open retrieve and close
Open FName For Input As #FNumb
FileContentsString = Input(FileLen(FName), #FNumb)
Close #FNumb

'split contents into array and retrieve number of lines
FileContentsArray = Split(FileContentsString, vbNewLine)
NumberOfLinesToProcess = UBound(FileContentsArray) + 1

'setup user interface
ProgressBar1.Max = NumberOfLinesToProcess
ProgressBar1.Value = 0
ProgressBar1.Visible = True

DoEvents 'make sure pb is visible

'run through contents
For I = 0 To NumberOfLinesToProcess - 1
ProgressBar1.Value = I
ProgressBar1.Refresh 'update user or doevents
'.... do processing here
Next I

'hide progress bar
ProgressBar1.Visible = False

Exit Sub
ProcessFileContentsError:

MsgBox Err.Description

End Sub
[/tt]

but if you are reading an ini file with the api you will have to go about it a little differently (per your last thread)

Good Luck

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top